dat.h (953B)
1 #ifndef DAT_H 2 #define DAT_H 3 4 #include <stdint.h> 5 6 #define MEMORY_SIZE 65536 7 8 #define REG_A 0b111 9 #define REG_B 0b000 10 #define REG_C 0b001 11 #define REG_D 0b010 12 #define REG_E 0b011 13 #define REG_H 0b100 14 #define REG_L 0b101 15 #define REG_M 0b110 16 17 #define OP_ZZ 0b00 18 #define OP_MV 0b01 19 #define OP_ALU 0b10 20 #define OP_OO 0b11 21 22 #define OP_ALU_ADD 0b000 23 #define OP_ALU_ADC 0b001 24 #define OP_ALU_SUB 0b010 25 #define OP_ALU_SBB 0b011 26 #define OP_ALU_ANA 0b100 27 #define OP_ALU_XRA 0b101 28 #define OP_ALU_ORA 0b110 29 #define OP_ALU_CMP 0b111 30 31 #define OP_INC 0b100 32 #define OP_DEC 0b101 33 34 #define OP_JMP 0b011 35 #define OP_J 0b010 36 37 #define F_CY 0 /* carry */ 38 #define F_P 2 /* parity */ 39 #define F_AC 4 /* auxiliary carry */ 40 #define F_Z 6 /* zero */ 41 #define F_S 7 /* sign */ 42 43 typedef struct { 44 uint8_t mem[MEMORY_SIZE]; 45 uint8_t a; 46 uint8_t b; 47 uint8_t c; 48 uint8_t d; 49 uint8_t e; 50 uint8_t h; 51 uint8_t l; 52 uint16_t pc; 53 uint8_t f; 54 } emu_t; 55 56 #endif /* DAT_H */