Incomplete, but I want to make sure the ideas I have here don't get wiped. Sadly this commit won't compile.
This commit is contained in:
+11
-13
@@ -18,7 +18,7 @@ Instruction instructions[OPCODECOUNT] = {
|
||||
{ "call", CALL, Address, None}
|
||||
};
|
||||
|
||||
unsigned char GetInstructionMask(TokenType type) {
|
||||
unsigned char GetInstructionMask(Mnemonic type) {
|
||||
switch (type) {
|
||||
case COPY:
|
||||
return 0x20; //0b00100000; ORing 0x80 marks the first parameter as an address
|
||||
@@ -93,7 +93,7 @@ Register registers[REGISTERCOUNT] = {
|
||||
{ "r8", R8 }
|
||||
};
|
||||
|
||||
const Instruction* GetOpcodeDetails(TokenType type) {
|
||||
const Instruction* GetOpcodeDetails(Mnemonic type) {
|
||||
for(int i = 0; i < OPCODECOUNT; i++) {
|
||||
if (instructions[i].op == type) return &instructions[i];
|
||||
}
|
||||
@@ -101,12 +101,12 @@ const Instruction* GetOpcodeDetails(TokenType type) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int IsOpcode(const char* text, TokenType* opcode) {
|
||||
int IsOpcode(const char* text, Mnemonic* opcode) {
|
||||
if (!text) return 0;
|
||||
|
||||
for(int i = 0; i < OPCODECOUNT; i++) {
|
||||
if (strcmp(instructions[i].lexeme, text) == 0) {
|
||||
if (opcode) *opcode = instructions[i].op;
|
||||
if (strcmp(instructions[i], text) == 0) {
|
||||
if (opcode) *opcode = instructions[i].Mnemonic;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -114,15 +114,13 @@ int IsOpcode(const char* text, TokenType* opcode) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int IsRegister(const char* text, TokenType* reg) {
|
||||
int IsRegister(const char* text, Registers* reg) {
|
||||
if (!text) return 0;
|
||||
|
||||
for(int i = 0; i < REGISTERCOUNT; i++) {
|
||||
if (strcmp(registers[i].lexeme, text) == 0) {
|
||||
*reg = registers[i].type;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
int length = strlen(text);
|
||||
|
||||
return 0;
|
||||
if (length != 2) return 0;
|
||||
if (text[0] != 'r') return 0;
|
||||
|
||||
return text[1] >= '1' && text[1] <= '8';
|
||||
}
|
||||
Reference in New Issue
Block a user