Some refactoring to update everything to use the new structures and some new considerations for how Symbols and Instructions shoudl be represented.
This commit is contained in:
+8
-6
@@ -4,8 +4,6 @@
|
||||
#include <string.h>
|
||||
#include "symbols_table.h"
|
||||
|
||||
#define OPCODECOUNT 13
|
||||
|
||||
typedef enum {
|
||||
R1, R2, R3, R4, R5, R6, R7, R8
|
||||
} Registers;
|
||||
@@ -16,9 +14,10 @@ typedef enum {
|
||||
} Mnemonic;
|
||||
|
||||
typedef enum {
|
||||
None,
|
||||
Constant,
|
||||
Address
|
||||
NoParameter,
|
||||
ConstantParameter,
|
||||
AddressParameter,
|
||||
RegisterParameter
|
||||
} OpcodeParameter;
|
||||
|
||||
typedef struct {
|
||||
@@ -37,10 +36,13 @@ typedef struct {
|
||||
} ParameterTwo;
|
||||
} Instruction;
|
||||
|
||||
extern Instruction instructions[OPCODECOUNT];
|
||||
//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);
|
||||
|
||||
|
||||
+14
-14
@@ -18,24 +18,24 @@
|
||||
// int resolved;
|
||||
// } Symbol;
|
||||
|
||||
typedef struct {
|
||||
Mnemonic Mnemonic;
|
||||
TokenClass ParameterOneType;
|
||||
TokenClass ParameterTwoType;
|
||||
// typedef struct {
|
||||
// Mnemonic Mnemonic;
|
||||
// TokenClass ParameterOneType;
|
||||
// TokenClass ParameterTwoType;
|
||||
|
||||
union {
|
||||
uint16_t Constant;
|
||||
Symbol* Address;
|
||||
} ParameterOne;
|
||||
// union {
|
||||
// uint16_t Constant;
|
||||
// Symbol* Address;
|
||||
// } ParameterOne;
|
||||
|
||||
union {
|
||||
uint16_t Constant;
|
||||
Symbol* Address;
|
||||
} ParameterTwo;
|
||||
} IROpcode;
|
||||
// union {
|
||||
// uint16_t Constant;
|
||||
// Symbol* Address;
|
||||
// } ParameterTwo;
|
||||
// } IROpcode;
|
||||
|
||||
typedef struct {
|
||||
List* Opcodes;
|
||||
List* Instructions;
|
||||
SymbolTable* SymbolsTable;
|
||||
} IRState;
|
||||
|
||||
|
||||
@@ -8,11 +8,21 @@
|
||||
|
||||
#define SYMBOLSTABLE_DEFAULT_CAPACITY 128
|
||||
|
||||
typedef enum {
|
||||
Data,
|
||||
Address
|
||||
} SymbolType;
|
||||
|
||||
typedef struct {
|
||||
void* Value;
|
||||
char* Name;
|
||||
int Length;
|
||||
int Resolved;
|
||||
|
||||
union {
|
||||
char* Text;
|
||||
int Number;
|
||||
//Instruction Instruction;
|
||||
} Value;
|
||||
} Symbol;
|
||||
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user