diff --git a/src/pasm_vm.c b/src/pasm_vm.c index df6a766..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 == arg; + vm.f = vm.r1 == arg; break; case OP_JMP_IF_F: diff --git a/src/to_bytecode.c b/src/to_bytecode.c index bb258fc..92df6cf 100644 --- a/src/to_bytecode.c +++ b/src/to_bytecode.c @@ -75,6 +75,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++;