diff options
| author | taitep <taitep@taitep.se> | 2025-12-22 19:19:19 +0100 |
|---|---|---|
| committer | taitep <taitep@taitep.se> | 2025-12-22 19:19:19 +0100 |
| commit | ff161a69e6ae5bc63e3152eda1508db05e8a33ba (patch) | |
| tree | 5a184eeac9a4daad8cbb28d0d0f066a488f9b2a9 /src/instructions/rvi.rs | |
| parent | e00103375ddf2ccece47a7db0ee5fca3fc3d3502 (diff) | |
Implement ADD
Diffstat (limited to 'src/instructions/rvi.rs')
| -rw-r--r-- | src/instructions/rvi.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/instructions/rvi.rs b/src/instructions/rvi.rs index 0920e80..608b1ae 100644 --- a/src/instructions/rvi.rs +++ b/src/instructions/rvi.rs @@ -11,6 +11,16 @@ use crate::{ mem::PageNum, }; +pub fn add(core: &mut Core, instr: Instruction) -> InstructionResult { + core.reg_write( + instr.rd(), + core.reg_read(instr.rs1()) + .wrapping_add(core.reg_read(instr.rs2())), + ); + core.advance_pc(); + InstructionResult::Normal +} + pub fn addi(core: &mut Core, instr: Instruction) -> InstructionResult { core.reg_write( instr.rd(), |
