aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormryouse2023-06-08 22:11:32 -0400
committermryouse2023-06-08 22:11:32 -0400
commit4244efa55d29d3fa20d5fcba3ada1f423f87ec52 (patch)
treeac1bd7f9d63eafd243f5952a38e0a0d59aa5ff0f
parent4446f10ea78f03202e963ec67ff6010e56637287 (diff)
bugfix (probably wrong): this *seems* to stop the offset issues on stack B, but I'm not sure why
-rw-r--r--vm.d8
1 files changed, 5 insertions, 3 deletions
diff --git a/vm.d b/vm.d
index 69a16dc..2287f87 100644
--- a/vm.d
+++ b/vm.d
@@ -93,8 +93,9 @@ class VM {
if (offset >= this.bTop) {
writefln("peekB() offset of %d greater than stack size %d", offset, this.bTop);
}
- return this.bStack[this.bTop - offset];
- //return this.bStack[this.bTop - offset - 1];
+ //return this.bStack[this.bTop];
+ //return this.bStack[this.bTop - offset];
+ return this.bStack[this.bTop - offset - 1];
}
Value popB() {
@@ -275,6 +276,7 @@ class VM {
}
while (true) {
if (DEBUG) {
+ writefln(" atop: %d, btop: %d", this.aTop, this.bTop);
writeln(" Stacks:");
write(" A> ");
for (int i = 0; i < this.aTop; i++) {
@@ -385,7 +387,7 @@ class VM {
//pushA(current.slots[current.frameStart + slot + 1]);
//pushA(this.current.slots[this.current.frameStart + slot]);
- pushA(this.peekB(this.bTop - (this.current.frameStart + slot)));
+ pushA(this.peekB(this.bTop - (this.current.frameStart + slot) - 1));
break;
case OpCode.OP_SET_LOCAL:
ubyte slot = this.readByte();