Advertisement
S0lll0s

QoreWars Opcodes

Dec 2nd, 2013
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. // See https://github.com/S0lll0s/QoreWars
  2.  
  3. 00001/110/001/000 ; = 1/6/1/0 = 1<<9 (MOV) + 6<<6 (I) + 1<<3 (B_DIR) + 0<<0 (A_IMM) = MOV.I #, $
  4. 00000/110/000/111 ; = 0/6/0/7 = 0<<9 (DAT) + 6<<6 (I) + 0<<3 (B_IMM) + 7<<0 (A_IMM) = DAT.I #, #
  5. 01100/001/011/010 ; = 12/1/3/2 = 12<<9 (SEQ) + 1<<6 (B) + 3<<3 (B_BIN) + 2<<0 (A_AIN) = SEQ.B #, *
  6. 10001/000/000/001 ; = 17/0/0/1 = 17<<9 (NOP) + 0<<6 (A) + 0<<3 (B_IMM) + 1<<0 (A_DIR) = NOP.A $, #
  7.  
  8. -----------------------------
  9. #ifndef _H_DEFINES_
  10. #define _H_DEFINES_
  11.  
  12. /** ADDRessing mode Bits for the B-Field **/
  13. #define ADDR_A_IMM 0 << 0 // # - IMMediate
  14. #define ADDR_A_DIR 1 << 0 // $ - DIRect
  15. #define ADDR_A_AIN 2 << 0 // * - A-INdirect
  16. #define ADDR_A_BIN 3 << 0 // @ - B-INdirect
  17. #define ADDR_A_APD 4 << 0 // { - A-indirect PreDecrement
  18. #define ADDR_A_BPD 5 << 0 // < - B-indirect PreDecrement
  19. #define ADDR_A_API 6 << 0 // } - A-indirect PostIncrement
  20. #define ADDR_A_BPI 7 << 0 // > - B-indirect PostIncrement
  21.  
  22. /** ADDRessing mode Bits for the B-Field **/
  23. #define ADDR_B_IMM 0 << 3 // # - IMMediate
  24. #define ADDR_B_DIR 1 << 3 // $ - DIRect
  25. #define ADDR_B_AIN 2 << 3 // * - A-INdirect
  26. #define ADDR_B_BIN 3 << 3 // @ - B-INdirect
  27. #define ADDR_B_APD 4 << 3 // { - A-indirect PreDecrement
  28. #define ADDR_B_BPD 5 << 3 // < - B-indirect PreDecrement
  29. #define ADDR_B_API 6 << 3 // { - A-indirect PostIncrement
  30. #define ADDR_B_BPI 7 << 3 // < - B-indirect PostIncrement
  31.  
  32. /** INSTruction Modifier Bits **/
  33. #define INST_M_A 0 << 6
  34. #define INST_M_B 1 << 6
  35. #define INST_M_AB 2 << 6
  36. #define INST_M_BA 3 << 6
  37. #define INST_M_F 4 << 6
  38. #define INST_M_X 5 << 6
  39. #define INST_M_I 6 << 6
  40.  
  41. /** INSTruction bits **/
  42. #define INST_DAT 0 << 9
  43. #define INST_MOV 1 << 9
  44. #define INST_ADD 2 << 9
  45. #define INST_SUB 3 << 9
  46. #define INST_MUL 4 << 9
  47. #define INST_DIV 5 << 9
  48. #define INST_MOD 6 << 9
  49. #define INST_JMP 7 << 9
  50. #define INST_JMZ 8 << 9
  51. #define INST_JMN 9 << 9
  52. #define INST_DJN 10 << 9
  53. #define INST_SPL 11 << 9
  54. #define INST_SEQ 12 << 9 // = INST_CMP
  55. #define INST_SNE 13 << 9
  56. #define INST_SLT 14 << 9
  57. #define INST_LDP 15 << 9
  58. #define INST_STP 16 << 9
  59. #define INST_NOP 17 << 9
  60.  
  61. typedef int Instruction;
  62.  
  63. typedef struct opcode {
  64. Instruction i;
  65. int a;
  66. int b;
  67. } Opcode;
  68.  
  69. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement