| 984 | } |
| 985 | |
| 986 | #[test] |
| 987 | fn test_subtract() { |
| 988 | // 100 - 37 = 63 |
| 989 | let (_, outcome) = assemble_and_run(vec![ |
| 990 | ri(RealInstruction::Addi(Addi::new(11, 0, 100))), // a1 = 100 |
| 991 | ri(RealInstruction::Addi(Addi::new(12, 0, 37))), // a2 = 37 |
| 992 | ri(RealInstruction::Sub(Sub::new(10, 11, 12))), // a0 = 100 - 37 = 63 |
| 993 | ri(RealInstruction::Addi(Addi::new(17, 0, 93))), // a7 = 93 |
| 994 | ri(RealInstruction::Ecall(Ecall::new())), |
| 995 | ]); |
| 996 | assert!( |
| 997 | matches!(outcome, StepOutcome::Halted(63)), |
| 998 | "expected Halted(63), got {outcome:?}" |
| 999 | ); |
| 1000 | } |
| 1001 | |
| 1002 | #[test] |
| 1003 | fn test_memory_store_load() { |
| 1004 | // t0=x5, t1=x6, sp=x2, a0=x10, a7=x17 |
| 1005 | // Store 99 to stack scratch space, load it back into a0, exit with it. |