-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dw/mips-makefile-import' into martin/gen-state-json
- Loading branch information
Showing
42 changed files
with
948 additions
and
101 deletions.
There are no files selected for viewing
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
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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,22 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
li t0, 5 # t0 = 5 | ||
li t1, 10 # t1 = 10 | ||
|
||
# Swap t0 and t1 using add | ||
add t2, t0, t1 # t2 = t0 + t1 (t2 = 5 + 10 = 15) | ||
sub t0, t2, t0 # t0 = t2 - t0 (t0 = 15 - 5 = 10) | ||
sub t1, t2, t1 # t1 = t2 - t1 (t1 = 15 - 10 = 5) | ||
|
||
# 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 |
20 changes: 20 additions & 0 deletions
20
o1vm/resources/programs/riscv32im/src/addi_boundary_immediate.S
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,20 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
li t0, 100 # t0 = 100 | ||
addi t1, t0, 2047 # t1 = t0 + 2047 (Expected: t1 = 2147) | ||
|
||
li t2, 1000 # t2 = 1000 | ||
addi t3, t2, -2048 # t3 = t2 + (-2048) (Expected: t1 = -1048) | ||
|
||
# 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
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,23 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
li t0, 2147483647 # t0 = 2147483647 (Max 32-bit signed int) | ||
addi t1, t0, 1 # t1 = t0 + 1 (Expected: overflow to -2147483648) | ||
|
||
li t2, -2147483648 # t2 = -2147483648 (Min 32-bit signed int) | ||
addi t3, t2, -1 # t3 = t2 + (-1) (Expected: overflow to 2147483647) | ||
|
||
li t4, 123456789 # t4 = 123456789 | ||
addi t5, t4, 0 # t5 = t4 + 0 (Expected: t4 = 123456789) | ||
|
||
# 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,30 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
|
||
# Simple AND | ||
li t0, 0b1100 # t0 = 0b1100 | ||
li t1, 0b1010 # t1 = 0b1010 | ||
and t2, t0, t1 # t2 = t0 & t1 (Expected: t2 = 0b1000) | ||
|
||
# AND with zero (result always zero) | ||
li t3, 0b1111 # t3 = 0b1111 | ||
li t4, 0 # t4 = 0 | ||
and t5, t3, t4 # t5 = t3 & t4 (Expected: t5 = 0) | ||
|
||
# AND of identical values (result same value) | ||
li t6, 0b1010 # t6 = 0b1010 | ||
li t0, 0b1010 # t0 = 0b1010 | ||
and t1, t6, t0 # t1 = t6 & t0 (Expected: t1 = 0b1010) | ||
|
||
# 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,19 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
# Signed division by zero (div) | ||
li t0, 42 # t0 = 42 | ||
li t1, 0 # t1 = 0 | ||
div t2, t0, t1 # t2 = t0 / t1 (Expected: division by zero) | ||
|
||
# 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,19 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
# Unsigned division by zero (div) | ||
li t0, 42 # t0 = 42 | ||
li t1, 0 # t1 = 0 | ||
divu t2, t0, t1 # t2 = t0 / t1 (Expected: division by zero) | ||
|
||
# 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 | ||
.global _start | ||
|
||
# t0 <- t0 + t1 | ||
add_t0_t1: | ||
add t0, t0, t1 | ||
ret | ||
|
||
_start: | ||
li t0, 5 | ||
li t1, 7 | ||
# Could be jalr | ||
# jal without offset | ||
jal ra, add_t0_t1 | ||
|
||
# exit | ||
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,18 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
li t0, 10000000 # Large number | ||
li t1, 10000000 # Another large number | ||
mul t2, t0, t1 # Test large multiplication (Expected overflow) | ||
|
||
# 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,19 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
# Signed remainder by zero (rem) | ||
li t0, 42 # t0 = 42 | ||
li t1, 0 # t1 = 0 | ||
rem t2, t0, t1 # t2 = t0 % t1 (Expected: remainder by zero) | ||
|
||
# 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,19 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
# Unsigned remainder by zero (remu) | ||
li t0, 42 # t0 = 42 | ||
li t1, 0 # t1 = 0 | ||
remu t2, t0, t1 # t2 = t0 % t1 (Expected: remainder by zero) | ||
|
||
# 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,30 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
|
||
# SLT with t0 < t1 (Expected: 1) | ||
li t0, 100 # t0 = 100 | ||
li t1, 200 # t1 = 200 | ||
slt t2, t0, t1 # t2 = (t0 < t1) ? 1 : 0 (Expected: t2 = 1) | ||
|
||
# SLT with t3 > t4 (Expected: 0) | ||
li t3, 300 # t3 = 300 | ||
li t4, 200 # t4 = 200 | ||
slt t5, t3, t4 # t5 = (t3 < t4) ? 1 : 0 (Expected: t5 = 0) | ||
|
||
# SLT with t0 == t1 (Expected: 0) | ||
li t0, 150 # t6 = 150 | ||
li t1, 150 # t7 = 150 | ||
slt t6, t0, t1 # t6 = (t0 < t1) ? 1 : 0 (Expected: t6 = 0) | ||
|
||
# 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.section .text | ||
.globl _start | ||
|
||
_start: | ||
|
||
# Simple XOR | ||
li t0, 0b1100 # t0 = 0b1100 | ||
li t1, 0b1010 # t1 = 0b1010 | ||
xor t2, t0, t1 # t2 = t0 ^ t1 (Expected: t2 = 0b0110) | ||
|
||
# XOR with zero (no change) | ||
li t3, 0b1010 # t3 = 0b1010 | ||
li t4, 0 # t4 = 0 | ||
xor t5, t3, t4 # t5 = t3 ^ t4 (Expected: t5 = 0b1010) | ||
|
||
# XOR of identical values (result 0) | ||
li t6, 0b1111 # t6 = 0b1111 | ||
li t0, 0b1111 # t0 = 0b1111 | ||
xor t1, t6, t0 # t1 = t6 ^ t0 (Expected: t1 = 0) | ||
|
||
# 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 |
Oops, something went wrong.