'RISC-V: How can I change this code into a full fibonacci sequence?
This is the code that was given to me and I am asked to modify it in order to the full Fibonacci sequence and get outputs for n = 10 and n = 18. I've tried adding ecalls between lines but I can't seem to figure it out.
.data .word 2, 4, 6, 8 n: .word 10
.text main: add t0, x0, x0 addi t1, x0, 1 la t3, n lw t3, 0(t3) fib: beq t3, x0, finish add t2, t1, t0 mv t0, t1 mv t1, t2 addi t3, t3, -1 j fib finish: addi a0, x0, 1 addi a1, t0, 0 ecall # print integer ecall addi a0, x0, 10 ecall # terminate ecall
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
