Skip to content

Commit

Permalink
Add test for addiu
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Dec 1, 2023
1 parent 6637576 commit d06a168
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions optimism/src/mips/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,23 @@ mod tests {
interpret_itype(&mut dummy_env, ITypeInstruction::LoadUpperImmediate);
assert_eq!(dummy_env.registers[REGISTER_AT as usize], 0xa0000);
}

#[test]
fn test_unit_addiu_instruction() {
// We only care about instruction parts and instruction pointer
let mut dummy_env = dummy_env();
// Instruction: 0b00100100001000010110110011101000
// lui at, 0xa
dummy_env.instruction_parts = InstructionParts {
op_code: 0b001001,
rs: 0b00001,
rt: 0b00001,
rd: 0b01101,
shamt: 0b10011,
funct: 0b101000,
};
let exp_res = dummy_env.registers[REGISTER_AT as usize] + 27880;
interpret_itype(&mut dummy_env, ITypeInstruction::AddImmediateUnsigned);
assert_eq!(dummy_env.registers[REGISTER_AT as usize], exp_res);
}
}

0 comments on commit d06a168

Please sign in to comment.