Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // See https://github.com/S0lll0s/QoreWars
- 00001/110/001/000 ; = 1/6/1/0 = 1<<9 (MOV) + 6<<6 (I) + 1<<3 (B_DIR) + 0<<0 (A_IMM) = MOV.I #, $
- 00000/110/000/111 ; = 0/6/0/7 = 0<<9 (DAT) + 6<<6 (I) + 0<<3 (B_IMM) + 7<<0 (A_IMM) = DAT.I #, #
- 01100/001/011/010 ; = 12/1/3/2 = 12<<9 (SEQ) + 1<<6 (B) + 3<<3 (B_BIN) + 2<<0 (A_AIN) = SEQ.B #, *
- 10001/000/000/001 ; = 17/0/0/1 = 17<<9 (NOP) + 0<<6 (A) + 0<<3 (B_IMM) + 1<<0 (A_DIR) = NOP.A $, #
- -----------------------------
- #ifndef _H_DEFINES_
- #define _H_DEFINES_
- /** ADDRessing mode Bits for the B-Field **/
- #define ADDR_A_IMM 0 << 0 // # - IMMediate
- #define ADDR_A_DIR 1 << 0 // $ - DIRect
- #define ADDR_A_AIN 2 << 0 // * - A-INdirect
- #define ADDR_A_BIN 3 << 0 // @ - B-INdirect
- #define ADDR_A_APD 4 << 0 // { - A-indirect PreDecrement
- #define ADDR_A_BPD 5 << 0 // < - B-indirect PreDecrement
- #define ADDR_A_API 6 << 0 // } - A-indirect PostIncrement
- #define ADDR_A_BPI 7 << 0 // > - B-indirect PostIncrement
- /** ADDRessing mode Bits for the B-Field **/
- #define ADDR_B_IMM 0 << 3 // # - IMMediate
- #define ADDR_B_DIR 1 << 3 // $ - DIRect
- #define ADDR_B_AIN 2 << 3 // * - A-INdirect
- #define ADDR_B_BIN 3 << 3 // @ - B-INdirect
- #define ADDR_B_APD 4 << 3 // { - A-indirect PreDecrement
- #define ADDR_B_BPD 5 << 3 // < - B-indirect PreDecrement
- #define ADDR_B_API 6 << 3 // { - A-indirect PostIncrement
- #define ADDR_B_BPI 7 << 3 // < - B-indirect PostIncrement
- /** INSTruction Modifier Bits **/
- #define INST_M_A 0 << 6
- #define INST_M_B 1 << 6
- #define INST_M_AB 2 << 6
- #define INST_M_BA 3 << 6
- #define INST_M_F 4 << 6
- #define INST_M_X 5 << 6
- #define INST_M_I 6 << 6
- /** INSTruction bits **/
- #define INST_DAT 0 << 9
- #define INST_MOV 1 << 9
- #define INST_ADD 2 << 9
- #define INST_SUB 3 << 9
- #define INST_MUL 4 << 9
- #define INST_DIV 5 << 9
- #define INST_MOD 6 << 9
- #define INST_JMP 7 << 9
- #define INST_JMZ 8 << 9
- #define INST_JMN 9 << 9
- #define INST_DJN 10 << 9
- #define INST_SPL 11 << 9
- #define INST_SEQ 12 << 9 // = INST_CMP
- #define INST_SNE 13 << 9
- #define INST_SLT 14 << 9
- #define INST_LDP 15 << 9
- #define INST_STP 16 << 9
- #define INST_NOP 17 << 9
- typedef int Instruction;
- typedef struct opcode {
- Instruction i;
- int a;
- int b;
- } Opcode;
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement