Implement SUB

This commit is contained in:
2025-12-22 19:33:40 +01:00
parent d0d3775b88
commit cb100e92ac
2 changed files with 11 additions and 0 deletions

View File

@@ -21,6 +21,16 @@ pub fn add(core: &mut Core, instr: Instruction) -> InstructionResult {
InstructionResult::Normal
}
pub fn sub(core: &mut Core, instr: Instruction) -> InstructionResult {
core.reg_write(
instr.rd(),
core.reg_read(instr.rs1())
.wrapping_sub(core.reg_read(instr.rs2())),
);
core.advance_pc();
InstructionResult::Normal
}
pub fn addi(core: &mut Core, instr: Instruction) -> InstructionResult {
core.reg_write(
instr.rd(),