Skip to content

Commit

Permalink
Merge pull request #2897 from o1-labs/dw/more-tests-for-addi-negative
Browse files Browse the repository at this point in the history
o1vm/riscv32im: add one test for addi with negative values only
  • Loading branch information
dannywillems authored Dec 24, 2024
2 parents 90dcb5e + 2c55e6b commit 422f493
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Binary file modified o1vm/resources/programs/riscv32im/bin/addi_negative
Binary file not shown.
3 changes: 3 additions & 0 deletions o1vm/resources/programs/riscv32im/src/addi_negative.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ _start:
# Subtract 100 using addi (addi with negative immediate)
addi t2, t1, -100 # t2 = t1 + (-100) (Expected: t2 = -50)

li t3, -1000 # t3 = -1000
addi t4, t3, -500 # t4 = t0 + (-500) (Expected: t4 = -1500)

# Custom exit syscall
li a0, 0
li a1, 0
Expand Down
2 changes: 2 additions & 0 deletions o1vm/tests/test_riscv_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ fn test_addi_negative() {
assert_eq!(witness.registers[T0], 100);
assert_eq!(witness.registers[T1], 50);
assert_eq!(witness.registers[T2], (-50_i32) as u32);
assert_eq!(witness.registers[T3], (-1000_i32) as u32);
assert_eq!(witness.registers[T4], (-1500_i32) as u32);
}

#[test]
Expand Down

0 comments on commit 422f493

Please sign in to comment.