Newer
Older
emul / emul_mem.c
#include "emul_mem.h"
#include <stdio.h>

static char mem[EMUL_MEMSIZE];

int emul_mem_get(int address) {
    int word = 0;
    word |= mem[address+0] << 0;
    return word;
}

void emul_mem_set(int address, int byte) {
    mem[address+0] = (char)((byte >> 0 ) & 0x000F);
}

int emul_mem_get_word(int address) {
    int word = 0;
    word |= mem[address+0] << 0;
    word |= mem[address+1] << 8;
    word |= mem[address+2] << 16;
    word |= mem[address+3] << 24;
    return word;
}

void emul_mem_set_word(int address, int word) {
    mem[address+0] = (char)((word >> 0 ) & 0x000F);
    mem[address+1] = (char)((word >> 8 ) & 0x000F);
    mem[address+2] = (char)((word >> 16) & 0x000F);
    mem[address+3] = (char)((word >> 24) & 0x000F);
}