Updated the Instruction's structure and updated the Parser accordingly.

This commit is contained in:
2022-10-04 20:37:47 +00:00
parent 1f7989533b
commit 33309a2759
3 changed files with 97 additions and 36 deletions
+14 -16
View File
@@ -20,31 +20,29 @@ typedef enum {
RegisterParameter
} OpcodeParameter;
typedef struct {
OpcodeParameter ParameterType;
OpcodeParameter InterpretedAs;
union {
int Number; //ConstanrParam
Registers Register; //Register param
Symbol* Symbol; //Address param
} Value;
} Parameter;
typedef struct {
Mnemonic Mnemonic;
OpcodeParameter ParameterOneType;
OpcodeParameter ParameterTwoType;
int LineNumber;
union {
int Constant;
Symbol* Symbol;
} ParameterOne;
union {
int Constant;
Symbol* Symbol;
} ParameterTwo;
Parameter* ParameterOne;
Parameter* ParameterTwo;
} Instruction;
//extern Instruction instructions[OPCODECOUNT];
Instruction* CreateInstruction(Mnemonic mnemonic);
Parameter* CreateParameter(OpcodeParameter parameterType);
void FreeInstruction(Instruction* instruction);
int IsOpcode(const char*, Mnemonic*);
int IsRegister(const char*, Registers*);
void GetMnemonicText(Mnemonic mnemonic, char buffer[12]);
//const Instruction* GetOpcodeDetails(Mnemonic);
unsigned char GetInstructionMask(Mnemonic type);
#endif