diff options
| author | taitep <taitep@taitep.se> | 2025-12-22 19:25:19 +0100 |
|---|---|---|
| committer | taitep <taitep@taitep.se> | 2025-12-22 19:25:19 +0100 |
| commit | 1ddda6614a929ea141755d20a09f564d80e63b99 (patch) | |
| tree | 614ddd11e2915b46cfe70addf242dec84db36691 /src/instructions | |
| parent | ff161a69e6ae5bc63e3152eda1508db05e8a33ba (diff) | |
Implement AND and improve formatting and ordering in rvi.rs
Diffstat (limited to 'src/instructions')
| -rw-r--r-- | src/instructions/rvi.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/instructions/rvi.rs b/src/instructions/rvi.rs index 608b1ae..395fe8e 100644 --- a/src/instructions/rvi.rs +++ b/src/instructions/rvi.rs @@ -26,27 +26,35 @@ pub fn addi(core: &mut Core, instr: Instruction) -> InstructionResult { instr.rd(), core.reg_read(instr.rs1()).wrapping_add(instr.imm_i()), ); - core.advance_pc(); - InstructionResult::Normal } pub fn addiw(core: &mut Core, instr: Instruction) -> InstructionResult { let res = core.reg_read(instr.rs1()).wrapping_add(instr.imm_i()) as i32; - core.reg_write(instr.rd(), res as i64 as u64); - core.advance_pc(); + InstructionResult::Normal +} +pub fn and(core: &mut Core, instr: Instruction) -> InstructionResult { + core.reg_write( + instr.rd(), + core.reg_read(instr.rs1()) & core.reg_read(instr.rs2()), + ); + core.advance_pc(); InstructionResult::Normal } pub fn andi(core: &mut Core, instr: Instruction) -> InstructionResult { core.reg_write(instr.rd(), core.reg_read(instr.rs1()) & instr.imm_i()); - core.advance_pc(); + InstructionResult::Normal +} +pub fn slli(core: &mut Core, instr: Instruction) -> InstructionResult { + core.reg_write(instr.rd(), core.reg_read(instr.rs1()) << instr.imm_shamt()); + core.advance_pc(); InstructionResult::Normal } @@ -184,11 +192,3 @@ pub fn bne(core: &mut Core, instr: Instruction) -> InstructionResult { InstructionResult::Normal } - -pub fn slli(core: &mut Core, instr: Instruction) -> InstructionResult { - core.reg_write(instr.rd(), core.reg_read(instr.rs1()) << instr.imm_shamt()); - - core.advance_pc(); - - InstructionResult::Normal -} |
