view emulator/emu.h @ 9:ad2121f39b91

re-scratched the scratch code
author james <jb302@eecs.qmul.ac.uk>
date Sun, 08 Dec 2013 18:27:37 +0000
parents 3c8b4a4a1787
children
line wrap: on
line source
// emu.h
#ifndef EMU_H
#define EMU_H

typedef unsigned char BYTE;
typedef unsigned short WIDE;

struct
registers {
    // 8 bit registers
    BYTE A;
    BYTE R0;
    BYTE R1;
    BYTE R2;
    BYTE R3;
    BYTE flags;
    
    // 16 bit registers
    WIDE DPTR;
    WIDE SP;
    WIDE PC;
};

// 64kB byte-addressable main memory
BYTE
memory[0x10000];

// memory access function definitions
BYTE
read_mem(WIDE addr);

void
write_mem(BYTE data, WIDE addr);

// get byte at PC
BYTE
fetch(void);

// set PC
void
set(WIDE data);

#endif