Fri, 19 Nov 2010 16:06:12 +0000
Add new RK() helper and fix OP_ADD to use it (so it loads constants properly)
lvm.js | file | annotate | diff | comparison | revisions |
--- a/lvm.js Fri Nov 19 16:05:36 2010 +0000 +++ b/lvm.js Fri Nov 19 16:06:12 2010 +0000 @@ -294,6 +294,12 @@ return (INS_Bx(ins)-0x1FFFF); } +function RK(frame, R) +{ + var keysource = (R&0x100)?frame.f.constants:frame.reg; + return keysource[R&0xff]; +} + function LFunction(vm, chunk, env) { function F() {}; @@ -531,8 +537,8 @@ frame.pc+=INS_sBx(instruction); break; case OP_ADD: - var RB = frame.reg[INS_B(instruction)]; - var RC = frame.reg[INS_C(instruction)]; + var RB = RK(frame, INS_B(instruction)); + var RC = RK(frame, INS_C(instruction)); frame.reg[INS_A(instruction)] = RB.add(RC); break; case OP_SUB: