-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2899 from o1-labs/dw/sub-tests
o1vm/riscv32im: add tests for sub
- Loading branch information
Showing
7 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
|
||
# Test 1: Simple subtraction | ||
li t0, 1000 # t0 = 1000 | ||
li t1, 500 # t1 = 500 | ||
sub t2, t0, t1 # t2 = t0 - t1 (Expected: t2 = 500) | ||
|
||
# Test 2: Subtracting from zero | ||
li t3, 0 # t3 = 0 | ||
li t4, 100 # t4 = 100 | ||
sub t5, t3, t4 # t5 = t3 - t4 (Expected: t5 = -100) | ||
|
||
# Custom exit syscall | ||
li a0, 0 | ||
li a1, 0 | ||
li a2, 0 | ||
li a3, 0 | ||
li a4, 0 | ||
li a5, 0 | ||
li a6, 0 | ||
li a7, 42 | ||
ecall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
|
||
# Test 3: Subtracting a larger value (result negative) | ||
li t0, 300 # t0 = 300 | ||
li t1, 500 # t1 = 500 | ||
sub t2, t0, t1 # t2 = t0 - t1 (Expected: t2 = -200) | ||
|
||
# Test 4: Subtracting negative values (result positive) | ||
li t3, 100 # t3 = 100 | ||
li t4, -50 # t4 = -50 | ||
sub t5, t3, t4 # t5 = t3 - t4 (Expected: t5 = 150) | ||
|
||
# Custom exit syscall | ||
li a0, 0 | ||
li a1, 0 | ||
li a2, 0 | ||
li a3, 0 | ||
li a4, 0 | ||
li a5, 0 | ||
li a6, 0 | ||
li a7, 42 | ||
ecall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
# Test 5: Result of subtracting from a register (using same value) | ||
li t0, 1234 # t0 = 1234 | ||
sub t1, t0, t0 # t1 = t0 - t0 (Expected: t1 = 0) | ||
|
||
# Test 6: Handling overflow (large subtraction result) | ||
li t2, 2147483647 # t2 = 2147483647 (max positive signed 32-bit) | ||
li t3, -1 # t3 = -1 | ||
sub t4, t2, t3 # t4 = t2 - t3 (Expected: t0 = 2147483648, wraparound to -2147483648) | ||
# Custom exit syscall | ||
li a0, 0 | ||
li a1, 0 | ||
li a2, 0 | ||
li a3, 0 | ||
li a4, 0 | ||
li a5, 0 | ||
li a6, 0 | ||
li a7, 42 | ||
ecall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters