yemu/src/include/yemu/ocpu.h

87 lines
1.3 KiB
C

#ifndef YEMU_OCPU_H
#define YEMU_OCPU_H
#include <stdio.h>
#include <yemu/common.h>
#define MAX_MEMORY 1024*64
// Registers
#define REG_AL 0xA0
#define REG_AH 0xA1
#define REG_A 0x0A
#define REG_BL 0xB0
#define REG_BH 0xB1
#define REG_B 0x0B
#define REG_CL 0xC0
#define REG_CH 0xC1
#define REG_C 0x0C
#define REG_DL 0xD0
#define REG_DH 0xD1
#define REG_D 0x0D
#define REG_EL 0xE0
#define REG_EH 0xE1
#define REG_E 0x0E
#define REG_FL 0xF0
#define REG_FH 0xF1
#define REG_F 0x0F
// Opcodes
#define INS_MOV_IM 0x01
#define INS_MOV_REG 0xA1
#define INS_ADD_IM 0x10
#define INS_ADD_REG 0xB0
#define INS_INC 0x15
#define INS_DEC 0x16
#define INS_OCPU_NOP 0x90
struct OCPU_MEMORY {
byte memory[MAX_MEMORY];
};
struct OCPU {
word PC; // The program counter is a 16 bit register which points to the next instruction to be executed.
byte SP; // The stack pointer is an 8 bit register and holds the low 8 bits of the next free location on the stack.
byte AL;
byte AH;
word A;
byte BL;
byte BH;
word B;
byte CL;
byte CH;
word C;
byte DL;
byte DH;
word D;
byte EL;
byte EH;
word E;
byte FL;
byte FH;
word F;
// Flags (or Processor Status)
byte ZF; // Zero Flag
byte NF; // Negative Flag
byte CF; // Carry Flag
byte OF; // Overflow Flag
};
void initOCPU(FILE *infile);
#endif