Skip to content

Commit ef1dbb5

Browse files
committed
Add source code of "fibonacci" testbench
1 parent c8f9876 commit ef1dbb5

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

build/Fibonacci.elf

-217 KB
Binary file not shown.

build/fibonacci.elf

74.6 KB
Binary file not shown.

tests/fibonacci.s

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
fib:
2+
li a5,1
3+
bleu a0,a5,.L3
4+
addi sp,sp,-16
5+
sw ra,12(sp)
6+
sw s0,8(sp)
7+
sw s1,4(sp)
8+
mv s0,a0
9+
addi a0,a0,-1
10+
la t0,fib
11+
jalr ra,0(t0)
12+
mv s1,a0
13+
addi a0,s0,-2
14+
la t0,fib
15+
jalr ra,0(t0)
16+
add a0,s1,a0
17+
lw ra,12(sp)
18+
lw s0,8(sp)
19+
lw s1,4(sp)
20+
addi sp,sp,16
21+
jr ra
22+
.L3:
23+
li a0,1
24+
ret
25+
.LC0:
26+
.string "%d\n"
27+
.text
28+
.align 1
29+
.globl main
30+
.type main, @function
31+
main:
32+
addi sp,sp,-16
33+
sw ra,12(sp)
34+
li a0,42
35+
call fib
36+
mv a1,a0
37+
lui a0,%hi(.LC0)
38+
addi a0,a0,%lo(.LC0)
39+
call printf
40+
li a0,0
41+
lw ra,12(sp)
42+
addi sp,sp,16
43+
jr ra

0 commit comments

Comments
 (0)