From 19a297f42a2f321ead4c03290d38a8ccdbf8dc18 Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 23 May 2023 00:23:41 -0500 Subject: test & fix indirection & predecrement --- src/vm/core.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/vm/core.js') diff --git a/src/vm/core.js b/src/vm/core.js index 074e156..6303ee5 100644 --- a/src/vm/core.js +++ b/src/vm/core.js @@ -31,13 +31,13 @@ class Core { return this.normalize(pc, address.value); case AddrMode.Indirect: { let loc = this.normalize(pc, address.value); - let b = this.data[loc]; + let b = this.data[loc].b.value; return this.normalize(loc, b); } case AddrMode.Predecrement: { let loc = this.normalize(pc, address.value); - this.data[loc].b -= 1; - let b = this.data[loc].b; + this.data[loc].b.value -= 1; + let b = this.data[loc].b.value; return this.normalize(loc, b); } default: @@ -46,7 +46,8 @@ class Core { } getValue(pc, address) { - return this.data[this.getLocation(pc, address)]; + const index = this.getLocation(pc, address); + return this.data[index]; } } -- cgit v1.2.1