From 9f478261bc8fd1502090c701c998e48a4018e7ee Mon Sep 17 00:00:00 2001 From: sanine-a Date: Wed, 24 May 2023 13:06:45 -0500 Subject: fix operand resolution to match spec --- src/vm/instruction.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/vm/instruction.test.js') diff --git a/src/vm/instruction.test.js b/src/vm/instruction.test.js index cf23404..279b9b8 100644 --- a/src/vm/instruction.test.js +++ b/src/vm/instruction.test.js @@ -393,6 +393,21 @@ test('JMP correctly jumps', () => { }); +test('JMP correctly responds to B-field predecrement', () => { + const core = new Core(CORESIZE); + const pc = 2; + core.data[pc] = { + opcode: 'JMP', + a: { mode: 'direct', value: -3 }, + b: { mode: 'predecrement', value: 1 }, + }; + const ins = core.data[pc]; + + expect(JMP(core, pc, ins)).toEqual([CORESIZE-1]); + expect(core.data[pc+1].b.value).toBe(-1); +}); + + test('JMZ correctly jumps in non-immediate mode', () => { const core = new Core(CORESIZE); const pc = 2; -- cgit v1.2.1