Updated the opcode listing and 'fixed' the code to at least compile, but obviously I'll need to rework how the new copy instructions are to be parsed. Fixed some errors in the documentation where I skipped some hex numbers and added a copy immediate op.
This commit is contained in:
+5
-28
@@ -7,47 +7,24 @@
|
||||
//#include "symbols_table.h"
|
||||
|
||||
typedef enum {
|
||||
R1, R2, R3, R4, R5, R6, R7, R8
|
||||
R1 = 0, R2, R3, R4, R5, R6, R7, R8 = 7
|
||||
} Registers;
|
||||
|
||||
typedef enum {
|
||||
ADD, SUB, JZ, INT, YLD, RET,
|
||||
CMP, CMPI, NOP, JMP, CALL, LODW, LAA, LODWI, JE, INC, DEC, LOADB,
|
||||
STOB, STOW, JG, JL, AND, XOR, OR, NOT, SHR, SHL, POP, PUSH, LODB,
|
||||
JMPA, JZA, JLA, JGA
|
||||
COPYA = 0x08, COPYAB = 0x10, COPYRA = 0x18, COPYRAB = 0x20, COPYRARA = 0x28, COPYRARAB = 0x30, COPY = 0x38, COPYB = 0x40, COPYI = 0xC0,
|
||||
CMP = 0x48, CMPI = 0x50, ADD = 0x58, SUB = 0x60, AND = 0x68, XOR = 0x70, OR = 0x78, NOT = 0x80, SHR = 0x88, SHL = 0x90,
|
||||
INC = 0x98, DEC = 0xA0, PUSH = 0xA8, POP = 0xB0,
|
||||
JMPI = 0xB8, JMP = 0x02, JZ = 0x03, JG = 0x04, JL = 0x05, NOP = 0x01, CALL = 0x06, RET = 0x07
|
||||
} Mnemonic;
|
||||
|
||||
typedef enum {
|
||||
NoParameter = 1,
|
||||
ConstantParameter = 2,
|
||||
AddressParameter = 4,
|
||||
RegisterParameter = 8,
|
||||
UnresolvedParameter = 16
|
||||
} OpcodeParameter;
|
||||
|
||||
typedef struct {
|
||||
OpcodeParameter ParameterType;
|
||||
OpcodeParameter InterpretedAs;
|
||||
|
||||
union {
|
||||
int Number; //ConstanrParam
|
||||
Registers Register; //Register param
|
||||
char* Symbol; //Symbol* Symbol; //Address param
|
||||
} Value;
|
||||
} Parameter;
|
||||
|
||||
typedef struct {
|
||||
Mnemonic Mnemonic;
|
||||
Parameter* ParameterOne;
|
||||
Parameter* ParameterTwo;
|
||||
} Instruction;
|
||||
|
||||
Instruction* CreateInstruction(Mnemonic mnemonic);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user