#ifndef OPCODES_H #define OPCODES_H #include #include "symbols_table.h" typedef enum { R1, R2, R3, R4, R5, R6, R7, R8 } Registers; typedef enum { ADD, SUB, JZ, INT, YLD, RET, CMP, NOP, JMP, CALL, LOAD, JE, INC, DEC, LOADB } Mnemonic; typedef enum { NoParameter, ConstantParameter, AddressParameter, RegisterParameter } OpcodeParameter; typedef struct { Mnemonic Mnemonic; OpcodeParameter ParameterOneType; OpcodeParameter ParameterTwoType; union { int Constant; Symbol* Symbol; } ParameterOne; union { int Constant; Symbol* Symbol; } ParameterTwo; } Instruction; //extern Instruction instructions[OPCODECOUNT]; Instruction* CreateInstruction(Mnemonic mnemonic); 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