summaryrefslogtreecommitdiff
path: root/assembly/landingpad-test/landingpad-test.S
diff options
context:
space:
mode:
authorcheapie <cheapiephp@gmail.com>2026-06-23 18:54:53 -0500
committercheapie <cheapiephp@gmail.com>2026-06-23 18:54:53 -0500
commit3acb10122050d710845a7c35e84423cc1aae5632 (patch)
tree2eadd0c8514b7fd046621b26f79db156349c22e9 /assembly/landingpad-test/landingpad-test.S
parent41a6282fb32a3a7dbeca64191ddd804585bca5f4 (diff)
downloadrvcontroller-3acb10122050d710845a7c35e84423cc1aae5632.tar
rvcontroller-3acb10122050d710845a7c35e84423cc1aae5632.tar.gz
rvcontroller-3acb10122050d710845a7c35e84423cc1aae5632.tar.bz2
rvcontroller-3acb10122050d710845a7c35e84423cc1aae5632.tar.xz
rvcontroller-3acb10122050d710845a7c35e84423cc1aae5632.zip
Add Zicfilp extension and some CSR improvements
Diffstat (limited to 'assembly/landingpad-test/landingpad-test.S')
-rw-r--r--assembly/landingpad-test/landingpad-test.S52
1 files changed, 52 insertions, 0 deletions
diff --git a/assembly/landingpad-test/landingpad-test.S b/assembly/landingpad-test/landingpad-test.S
new file mode 100644
index 0000000..21c1712
--- /dev/null
+++ b/assembly/landingpad-test/landingpad-test.S
@@ -0,0 +1,52 @@
+li t0,0x400
+csrw mseccfg,t0 # Turn on MLPE (enable Zicfilp)
+
+li t0,1
+csrw 0x800,t0 # Enable lightweight mode (will make each pause 1s long)
+
+li a7,4
+la a0,test1msg
+ecall # Display test 1 explanation
+
+pause
+pause
+
+la s0,test1jump
+jalr zero,s0,0 # This jump lands on a landing pad
+
+.word 0 # Invalid instruction just to make sure the jump really happened
+
+test1jump:
+lpad 0
+li a7,4
+la a0,test1done
+ecall # Tell user we got here
+
+pause
+pause
+
+li a7,4
+la a0,test2msg
+ecall # Display test 2 explanation
+
+pause
+pause
+
+la s0,test2jump
+jalr zero,s0,0 # This jump doesn't land on a landing pad
+
+.word 0 # Another invalid instruction to jump over
+
+test2jump:
+# No landing pad! This should crash
+li a7,4
+la a0,test2done
+ecall # Tell user we got here (we shouldn't have!)
+
+li a7,10
+ecall
+
+test1msg: .asciz "Testing OK jump\nThis should work\n\n\n\n"
+test1done: .asciz "OK jump jumped\nThis is expected\n\n\n\n"
+test2msg: .asciz "Testing bad jump\nThis should crash\n\n\n\n"
+test2done: .asciz "Bad jump jumped!\nThis shouldn't\nhappen\n\n\n"