Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pushc <const>
- #define PUSHC 1 //1 is for the command value in the Opcode
- #define IMMEDIATE(x) ((x) & 0x00FFFFFF)
- **#define SIGN_EXTEND(i) ((i) & 0x00800000 ? (i) | 0xFF000000 : (i))**
- unsigned int code[] = { (PUSHC << 24 | IMMEDIATE(2)),
- (PUSHC << 24 | SIGN_EXTEND(-2)),
- ...};
- void exec(unsigned int IR){
- unsigned int opcode = (IR >> 24) & 0xff;
- unsigned int imm = (IR & 0xffffff);
- switch(opcode){
- case PUSHC: {
- stack[sp] = imm;
- sp = sp + 1;
- break;
- }
- }
- ...
- }
- }
- const uint8_t opcode = (IR >> 24) & 0xff;
- const uint32_t imm = (IR & 0xffffff);
- switch(opcode)
- {
- case PUSHC:
- stack[sp] = imm;
- break;
- }
Add Comment
Please, Sign In to add comment