Updated the ISA so the program will correctly see things like 'load', 'inc' and 'dec'.
This commit is contained in:
+9
-7
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define OPCODECOUNT 13
|
||||
#define OPCODECOUNT 15
|
||||
|
||||
struct _instruction {
|
||||
char* Name;
|
||||
@@ -10,7 +10,6 @@ struct _instruction {
|
||||
};
|
||||
|
||||
struct _instruction instructions[OPCODECOUNT] = {
|
||||
{ "copy", COPY },//, Reg | Address, Reg | Constant | Address },
|
||||
{ "add", ADD },//, Reg, Reg | Constant },
|
||||
{ "sub", SUB },//, Reg, Reg | Constant },
|
||||
{ "jz", JZ },//, Address, None },
|
||||
@@ -18,11 +17,14 @@ struct _instruction instructions[OPCODECOUNT] = {
|
||||
{ "yld", YLD },//, None, None },
|
||||
{ "ret", RET },//, None, None },
|
||||
{ "cmp", CMP },//, Reg, Reg | Constant },
|
||||
{ "in", IN },//, Constant | Reg, None},
|
||||
{ "out", OUT },//, None, None},
|
||||
{ "inc", INC },//, Constant | Reg, None},
|
||||
{ "dec", DEC },//, None, None},
|
||||
{ "nop", NOP },//, None, None},
|
||||
{ "jmp", JMP },//, Address, None},
|
||||
{ "call", CALL },//, Address, None}
|
||||
{ "load", LOAD },
|
||||
{ "je", JE },
|
||||
{ "loadb", LOADB}
|
||||
};
|
||||
|
||||
Instruction* CreateInstruction(Mnemonic mnemonic) {
|
||||
@@ -49,7 +51,7 @@ void FreeInstruction(Instruction* instruction) {
|
||||
|
||||
unsigned char GetInstructionMask(Mnemonic type) {
|
||||
switch (type) {
|
||||
case COPY:
|
||||
case LOAD:
|
||||
return 0x20; //0b00100000; ORing 0x80 marks the first parameter as an address
|
||||
case ADD:
|
||||
return 0x40;//0b01000000;
|
||||
@@ -69,9 +71,9 @@ unsigned char GetInstructionMask(Mnemonic type) {
|
||||
return 0x05;
|
||||
case JMP:
|
||||
return 0x06;//0b00000110;
|
||||
case IN:
|
||||
case INC:
|
||||
return 0x07;//0b00000111;
|
||||
case OUT:
|
||||
case DEC:
|
||||
return 0x08;//0b00001000;
|
||||
default:
|
||||
return 0x00;
|
||||
|
||||
Reference in New Issue
Block a user