Skip to content

Commit 0d994e8

Browse files
committed
jal: add unit test
1 parent 3c1645c commit 0d994e8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

optimism/src/mips/interpreter.rs

+22
Original file line numberDiff line numberDiff line change
@@ -806,4 +806,26 @@ mod tests {
806806
interpret_itype(&mut dummy_env, ITypeInstruction::BranchEqZeroJump);
807807
assert_eq!(dummy_env.instruction_pointer, ip + (10 + 1) * 4);
808808
}
809+
810+
#[test]
811+
fn test_unit_jal_instruction() {
812+
let mut dummy_env = dummy_env();
813+
let ip = dummy_env.instruction_pointer;
814+
// 0b00001100000000011110101111001001
815+
// jal 0x7af24
816+
dummy_env.instruction_parts = InstructionParts {
817+
op_code: 0b000011,
818+
rs: 0b00000,
819+
rt: 0b00001,
820+
rd: 0b11101,
821+
shamt: 0b01111,
822+
funct: 0b001001,
823+
};
824+
interpret_jtype(&mut dummy_env, JTypeInstruction::JumpAndLink);
825+
assert_eq!(dummy_env.instruction_pointer, 0x7af24);
826+
assert_eq!(
827+
dummy_env.registers.general_purpose[REGISTER_RA as usize],
828+
ip + 4
829+
);
830+
}
809831
}

0 commit comments

Comments
 (0)