diff options
author | Ashelyn Rose <git@ashen.earth> | 2024-12-06 15:10:31 -0700 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2024-12-06 15:10:31 -0700 |
commit | f5cebaf8feed5f5980df63a6c5b6a64d5d5ba092 (patch) | |
tree | b3cbadda8ecb13c77fae245917ac80e4ef2d4593 /src/interpreter.rs | |
parent | b902c11b89edc2d4e91d4bd1582792c9303bf874 (diff) |
Instruction parsing
Diffstat (limited to 'src/interpreter.rs')
-rw-r--r-- | src/interpreter.rs | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/src/interpreter.rs b/src/interpreter.rs index bc51754..39a33a8 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -1,6 +1,6 @@ use core::panic; -use crate::glk::Glk; +use crate::{glk::Glk, instructions::Instruction}; pub type MemAddress = u32; pub type StackAddress = u32; @@ -18,19 +18,6 @@ enum StubDestType { ResumeUnicodeString = 14, } -enum Nybble { - High, - Low, -} - -enum Operand { - Constant(i32), - PopStack, - FrameIndirect(StackAddress), - MemIndirect(MemAddress), - MemRamIndirect(MemAddress), -} - enum ReadWriteDest { Stack, Memory, @@ -100,11 +87,12 @@ impl Interpreter { self.reg_program = self.create_stack_frame(entry_func, Vec::new()); loop { - let instruction = self.load_program_instruction(); + let pc = self.reg_program as usize; + let mut instruction_slice = &self.memory[pc..pc+100]; + let (instruction, bytes_read) = Instruction::read(&mut instruction_slice); + self.reg_program += bytes_read; - match instruction { - _ => todo!("Haven't done any of the instruction loading yet") - } + println!("Parsed instruction {instruction:?}"); } } @@ -144,7 +132,7 @@ impl Interpreter { format_of_locals.push(format); }; - let opcode_start = local_pointer + 1; + let opcode_start = local_pointer + 2; // Writing stack frame self.reg_frame = self.reg_stack; @@ -214,10 +202,6 @@ impl Interpreter { return opcode_start; } - fn load_program_instruction(&mut self) { - - } - fn push_stack(&mut self, value: u32) { self.write_word(self.reg_stack, ReadWriteDest::Stack, value); self.reg_stack += 4; |