aboutsummaryrefslogtreecommitdiff
path: root/vm.d
diff options
context:
space:
mode:
Diffstat (limited to 'vm.d')
-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();