Added all the instructions supported to a structure to help make validation of parameters easier.

This commit is contained in:
2022-10-18 21:14:50 -05:00
parent 6d6bf1cbaf
commit 9a602824b6
2 changed files with 59 additions and 107 deletions
+8 -6
View File
@@ -12,15 +12,16 @@ typedef enum {
typedef enum {
ADD, SUB, JZ, INT, YLD, RET,
CMP, NOP, JMP, CALL, LOAD, JE, INC, DEC, LOADB
CMP, CMPI, NOP, JMP, CALL, LODW, LAA, LODWI, JE, INC, DEC, LOADB,
STOB, STOW, JG, JL, AND, XOR, OR, NOT, SHR, SHL
} Mnemonic;
typedef enum {
NoParameter,
ConstantParameter,
AddressParameter,
RegisterParameter,
UnresolvedParameter
NoParameter = 1,
ConstantParameter = 2,
AddressParameter = 4,
RegisterParameter = 8,
UnresolvedParameter = 16
} OpcodeParameter;
typedef struct {
@@ -45,6 +46,7 @@ Parameter* CreateParameter(OpcodeParameter parameterType);
void FreeInstruction(Instruction* instruction);
int IsOpcode(const char*, Mnemonic*);
int IsRegister(const char*, Registers*);
void ExpectParameters(Mnemonic mnemonic, OpcodeParameter* paramOne, OpcodeParameter* paramTwo);
void GetMnemonicText(Mnemonic mnemonic, char buffer[12]);
void GetRegisterText(Registers reg, char buffer[3]);
unsigned char GetInstructionMask(Mnemonic type);