summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/interpreter.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/interpreter.rs b/src/interpreter.rs
index 9f226ae..686a3ff 100644
--- a/src/interpreter.rs
+++ b/src/interpreter.rs
@@ -280,9 +280,9 @@ impl Interpreter {
             Operand::Constant(value) => *value as u32,
             Operand::PopStack => self.pop_stack(),
             Operand::FrameIndirect(offset) => {
-                let start_of_locals = self.get_word(self.reg_frame, ReadWriteDest::Stack);
-                assert!(start_of_locals + offset < self.reg_stack, "Frame offset out of frame");
-                self.get_word(start_of_locals + offset, ReadWriteDest::Stack)
+                let locals_pos = self.get_word(self.reg_frame + 4, ReadWriteDest::Stack);
+                assert!(self.reg_frame + locals_pos + offset < self.reg_stack, "Frame offset out of frame");
+                self.get_word(self.reg_frame + locals_pos + offset, ReadWriteDest::Stack)
             },
             Operand::MemIndirect(address) => {
                 // TODO: Handle heap
@@ -304,9 +304,9 @@ impl Interpreter {
             Operand::Constant(constant_dst) => panic!("Cannot store to constant operand {constant_dst}"),
             Operand::PopStack => self.push_stack(value),
             Operand::FrameIndirect(offset) => {
-                let start_of_locals = self.get_word(self.reg_frame, ReadWriteDest::Stack);
-                assert!(start_of_locals + offset < self.reg_stack, "Frame offset out of frame");
-                self.write_word(start_of_locals + offset, ReadWriteDest::Stack, value)
+                let locals_pos = self.get_word(self.reg_frame + 4, ReadWriteDest::Stack);
+                assert!(self.reg_frame + locals_pos + offset < self.reg_stack, "Frame offset out of frame");
+                self.write_word(self.reg_frame + locals_pos + offset, ReadWriteDest::Stack, value)
             },
             Operand::MemIndirect(address) => {
                 assert!(*address >= self.mem_writeable, "Cannot write to ROM");