Guest User

Untitled

a guest
Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. pushc <const>
  2.  
  3. #define PUSHC 1 //1 is for the command value in the Opcode
  4. #define IMMEDIATE(x) ((x) & 0x00FFFFFF)
  5.  
  6. **#define SIGN_EXTEND(i) ((i) & 0x00800000 ? (i) | 0xFF000000 : (i))**
  7.  
  8. unsigned int code[] = { (PUSHC << 24 | IMMEDIATE(2)),
  9. (PUSHC << 24 | SIGN_EXTEND(-2)),
  10. ...};
  11.  
  12. void exec(unsigned int IR){
  13.  
  14. unsigned int opcode = (IR >> 24) & 0xff;
  15. unsigned int imm = (IR & 0xffffff);
  16.  
  17. switch(opcode){
  18. case PUSHC: {
  19. stack[sp] = imm;
  20. sp = sp + 1;
  21. break;
  22. }
  23. }
  24.  
  25. ...
  26.  
  27. }
  28. }
  29.  
  30. const uint8_t opcode = (IR >> 24) & 0xff;
  31. const uint32_t imm = (IR & 0xffffff);
  32. switch(opcode)
  33. {
  34. case PUSHC:
  35. stack[sp] = imm;
  36. break;
  37. }
Add Comment
Please, Sign In to add comment