summaryrefslogtreecommitdiff
path: root/assembly/landingpad-test/landingpad-test.S
blob: 21c171208cb4f5e09c1b8aba03cd01175f10a3b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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"