Implement ADD

This commit is contained in:
2025-12-22 19:19:19 +01:00
parent e00103375d
commit ff161a69e6
2 changed files with 15 additions and 0 deletions

View File

@@ -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(),