diff options
author | David Li <li.davidm96@gmail.com> | 2015-12-20 14:59:22 -0500 |
---|---|---|
committer | David Li <li.davidm96@gmail.com> | 2015-12-20 14:59:22 -0500 |
commit | 80c073a5c4a992598ecaf36c58d2294f6aa766d0 (patch) | |
tree | 416a845f3055e38005545f9c87b2b6445c878cf9 /src/simulator.rs | |
parent | 8ca42acf1a92ac0d811bbeecf8aed25a8c2d5a30 (diff) |
Implement JAL, JALR
Diffstat (limited to 'src/simulator.rs')
-rw-r--r-- | src/simulator.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/simulator.rs b/src/simulator.rs index a7140fe..607a3b5 100644 --- a/src/simulator.rs +++ b/src/simulator.rs @@ -105,9 +105,16 @@ impl Simulator { // ret core.running = false; } + else { + let target = ((pc as i32) + inst.i_imm()) as usize; + core.registers.write_word(inst.rd(), pc + 4); + core.pc = target; + } }, isa::opcodes::JAL => { - + let target = ((pc as i32) + inst.uj_imm()) as usize; + core.registers.write_word(inst.rd(), pc + 4); + core.pc = target; } isa::opcodes::BRANCH => { |