diff options
Diffstat (limited to 'assembly/landingpad-test/landingpad-test.S')
| -rw-r--r-- | assembly/landingpad-test/landingpad-test.S | 52 |
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" |
