From 159ab62ebfae70a0fef61142602026df0b5e8b0e Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sat, 6 Jan 2024 16:44:19 -0500 Subject: [PATCH] opcode: JMP --- src/vm/instruction.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vm/instruction.rs b/src/vm/instruction.rs index 86cf402..92b0010 100644 --- a/src/vm/instruction.rs +++ b/src/vm/instruction.rs @@ -85,7 +85,7 @@ pub fn execute_instruction(vm: &mut VM, instr: u16) { OpCode::NOT => op_not(vm, instr), OpCode::LDI => op_ldi(vm, instr), OpCode::STI => op_sti(vm, instr), - OpCode::JMP => todo!("JMP"), + OpCode::JMP => op_jmp(vm, instr), OpCode::RES => todo!("RES"), OpCode::LEA => op_lea(vm, instr), OpCode::TRAP => op_trap(vm, instr), @@ -169,6 +169,13 @@ fn op_br(vm: &mut VM, instr: u16) { } } +fn op_jmp(vm: &mut VM, instr: u16) { + // RET is a special case of this where BaseR is R7 + let base_r = (instr >> 6) & 0b111; + + vm.registers.pc = vm.registers.get_reg(base_r); +} + //////////////// // Store ops ////////////////