-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.S
More file actions
40 lines (33 loc) · 746 Bytes
/
boot.S
File metadata and controls
40 lines (33 loc) · 746 Bytes
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
.section .text
.globl _start
_start:
# Argument: a0 = 30
li a0, 30
# Call fib(30)
call fib
# a0 now holds the result — exit via ecall (a7=93 for emulator exit)
li a7, 93 # syscall: exit
ecall
fib:
addi sp,sp,-32
sd ra,24(sp)
sd s0,16(sp)
mv s0,a0
li a5,1
bgt a0,a5,.L4
.L2:
mv a0,s0
ld ra,24(sp)
ld s0,16(sp)
addi sp,sp,32
jr ra
.L4:
sd s1,8(sp)
addiw a0,a0,-1
call fib
mv s1,a0
addiw a0,s0,-2
call fib
addw s0,s1,a0
ld s1,8(sp)
j .L2