From c7f8ede9223502a96a74adf0cb790ac41de04742 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 23 May 2023 12:43:07 -0500 Subject: correct indirection code to match spec --- src/vm/instruction.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/vm/instruction.test.js') diff --git a/src/vm/instruction.test.js b/src/vm/instruction.test.js index 82d9819..cf23404 100644 --- a/src/vm/instruction.test.js +++ b/src/vm/instruction.test.js @@ -76,7 +76,7 @@ test('MOV correctly handles indirection', () => { b: { mode: 'immediate', value: 2 }, }); - expect(core.data[pc+1]).toEqual({ + expect(core.data[pc+2]).toEqual({ opcode: 'DAT', a: { mode: 'immediate', value: 0 }, b: { mode: 'immediate', value: 100 }, @@ -93,18 +93,18 @@ test('MOV correctly handles predecrement indirection', () => { core.data[pc] = { opcode: 'MOV', a: { mode: 'immediate', value: 100 }, - b: { mode: 'predecrement', value: -1 }, + b: { mode: 'predecrement', value: 1 }, }; const ins = core.data[pc]; expect(core.data[pc+1].opcode).toBe('DAT'); expect(MOV(core, pc, ins)).toEqual([pc+1]); - expect(core.data[pc-1]).toEqual({ + expect(core.data[pc+1]).toEqual({ opcode: 'DAT', a: { mode: 'immediate', value: 0 }, b: { mode: 'immediate', value: -1 }, }); - expect(core.data[pc-2]).toEqual({ + expect(core.data[pc-1]).toEqual({ opcode: 'DAT', a: { mode: 'immediate', value: 0 }, b: { mode: 'immediate', value: 100 }, @@ -130,7 +130,7 @@ test('MOV correctly handles core boundaries', () => { b: { mode: 'immediate', value: -1 }, }); - expect(core.data[0]).toEqual({ + expect(core.data[CORESIZE-2]).toEqual({ opcode: 'DAT', a: { mode: 'immediate', value: 0 }, b: { mode: 'immediate', value: 100 }, -- cgit v1.2.1