Fri, 19 Nov 2010 20:52:08 +0000
Fix OP_LT to respect A, and move OP_EQ to live next to it in the switch() for readability
lvm.js | file | annotate | diff | comparison | revisions |
--- a/lvm.js Fri Nov 19 19:49:25 2010 +0000 +++ b/lvm.js Fri Nov 19 20:52:08 2010 +0000 @@ -24,7 +24,7 @@ var OP_FORPREP = 32; var OP_CLOSURE = 36; -var debugMode = false; +var debugMode = true; function LValue(vm, type, value) { @@ -567,13 +567,6 @@ case OP_JMP: frame.pc+=INS_sBx(instruction); break; - case OP_EQ: - var A = INS_A(instruction); - var RB = RK(frame, INS_B(instruction)); - var RC = RK(frame, INS_C(instruction)); - if(RB.equals(RC) != (A!=0)) - frame.pc++; - break; case OP_ADD: var RB = RK(frame, INS_B(instruction)); var RC = RK(frame, INS_C(instruction)); @@ -584,10 +577,18 @@ var RC = frame.reg[INS_C(instruction)]; frame.reg[INS_A(instruction)] = new LValue(this, "number", RB.value - RC.value); break; - case OP_LT: + case OP_EQ: + var A = INS_A(instruction); var RB = RK(frame, INS_B(instruction)); var RC = RK(frame, INS_C(instruction)); - if(RB.value < RC.value) + if(RB.equals(RC) != (A!=0)) + frame.pc++; + break; + case OP_LT: + var A = INS_A(instruction); + var RB = RK(frame, INS_B(instruction)); + var RC = RK(frame, INS_C(instruction)); + if(RB.value < RC.value != (A!=0)) frame.pc++; break; default: