Fixed a bug where CMP REG, REG wouldn't get encoded and a disassembler bug related to said CMP bug.
This commit is contained in:
+3
-3
@@ -2,9 +2,9 @@
|
||||
.db msg "Hello, world!", 0
|
||||
.db more_stuff "AA", 0
|
||||
copy r7, msg ; //
|
||||
cmp r8, 45 ;1000 1111
|
||||
add r4, 30
|
||||
sub r1, 69
|
||||
cmp r8, r3 ;1000 1111
|
||||
add r4, r1
|
||||
sub r1, r8
|
||||
int 20
|
||||
jz 45
|
||||
jmp msg
|
||||
|
||||
+3
-2
@@ -32,8 +32,9 @@ void Disassemble(unsigned char image[HIGHMEMORY]) {
|
||||
IsRegisterPattern(instruction & 0x07, parameter1);
|
||||
unsigned char parameterType = instruction & 0x18;
|
||||
|
||||
if (!parameterType) {
|
||||
IsRegisterPattern(Image[position], parameter2);
|
||||
if (parameterType == REGMASK) {
|
||||
IsRegisterPattern(Image[position + 1], parameter2);
|
||||
position += 2;
|
||||
} else if (parameterType == CONSTMASK) {
|
||||
snprintf(parameter2, sizeof(char) * 31, "%d", Image[position + 1] + Image[position + 2]);
|
||||
position += 3;
|
||||
|
||||
+10
-10
@@ -21,19 +21,19 @@ int main(int argc, char* args[]) {
|
||||
|
||||
List* list = GenerateTokenList(source_code);
|
||||
|
||||
// for(int i = 0; i < list->size; i++) {
|
||||
// Token* t = (Token*) list->content[i];
|
||||
for(int i = 0; i < list->size; i++) {
|
||||
Token* t = (Token*) list->content[i];
|
||||
|
||||
// if (t->type == LineEnd) {
|
||||
// if (i - 1 >= 0 && ((Token*) list->content[i - 1])->type != LineEnd)
|
||||
// printf("\n");
|
||||
if (t->type == LineEnd) {
|
||||
if (i - 1 >= 0 && ((Token*) list->content[i - 1])->type != LineEnd)
|
||||
printf("\n");
|
||||
|
||||
// continue;
|
||||
// }
|
||||
continue;
|
||||
}
|
||||
|
||||
// printf("[%i] '%s' [%i] ", t->type, t->lexeme, t->token_class);
|
||||
// if (t->type == LABEL) printf("* ");
|
||||
// }
|
||||
printf("[T: %i][C: %i] '%s' ", t->type, t->token_class, t->lexeme);
|
||||
if (t->type == LABEL) printf("* ");
|
||||
}
|
||||
|
||||
unsigned char* image = ParseTokens(list);
|
||||
Disassemble(image);
|
||||
|
||||
+10
-1
@@ -199,7 +199,16 @@ void HandleRegisterBasedOpcode(unsigned char instruction, unsigned char mask) {
|
||||
Memory[ProgramCounter + 1] = *value & 0xFF;
|
||||
|
||||
AdvanceParser();
|
||||
} else {
|
||||
}
|
||||
else if (token->token_class == Reg) {
|
||||
Memory[ProgramCounter] = (PeekToken()->type - R1) & 0x07;
|
||||
|
||||
AdvanceParser();
|
||||
|
||||
ProgramCounter++;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "[Error] Expected operand, got %s\n", token->lexeme);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user