From 0e286a34355b15096fe3ca1427c05a37978ffb08 Mon Sep 17 00:00:00 2001 From: sklassen1111 Date: Sat, 13 Oct 2018 23:22:21 -0400 Subject: [PATCH 1/2] Compare register R1 to ARG --- src/pasm_vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pasm_vm.c b/src/pasm_vm.c index 597d965..d7475c2 100644 --- a/src/pasm_vm.c +++ b/src/pasm_vm.c @@ -76,7 +76,7 @@ interpretation_result vm_interpret(uint32_t *bytecode) { break; case OP_CMP: - vm.f = vm.r0 == vm.r1; + vm.f = vm.r1 == arg; break; case OP_JMP_IF_F: From c6bc7b372b9f011bef83f4d9ba257f931f3d83be Mon Sep 17 00:00:00 2001 From: sklassen1111 Date: Sat, 13 Oct 2018 23:24:10 -0400 Subject: [PATCH 2/2] Moved CMP operator to parameter read statement --- src/to_bytecode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/to_bytecode.c b/src/to_bytecode.c index f242470..2b85cfe 100644 --- a/src/to_bytecode.c +++ b/src/to_bytecode.c @@ -72,6 +72,10 @@ uint32_t* to_bytecode(FILE* fp, uint32_t *bytecode) { } else if (!strcmp(op, "JMP_IF_NOT_F")) { bytecode[bytecode_idx] = 0x0f000000; bytecode[bytecode_idx] |= 0x00ffffff & atoi(arg); + } + else if (!strcmp(op, "CMP")) { + bytecode[bytecode_idx] = 0c0d000000; + bytecode[bytecode_idx] |= 0x00ffffff & atoi(arg); } else puts("IDIOT"); //printf("%x\n", bytecode[bytecode_idx]); bytecode_idx++; @@ -88,8 +92,6 @@ uint32_t* to_bytecode(FILE* fp, uint32_t *bytecode) { bytecode[bytecode_idx] = 0x07000000; else if (!strcmp(op, "XCHG")) bytecode[bytecode_idx] = 0x0c000000; - else if (!strcmp(op, "CMP")) - bytecode[bytecode_idx] = 0x0d000000; else if (!strcmp(op, "PRINT_R0")) bytecode[bytecode_idx] = 0x10000000; else if (!strcmp(op, "PRINT_R1"))