Question: ((((((((((((((((( Please solve in RiscV only))))))))))))Implement a function factorial in RISC-V that has a single integer parameter n and returns n!. A stub of this
((((((((((((((((( Please solve in RiscV only))))))))))))Implement a function factorial in RISC-V that has a single integer parameter n and returns n!. A stub of this function can be found in the file factorial.s. You will only need to add instructions under the factorial label, and the argument that is passed into the function is configured to be located at the label n. You may solve this problem using either recursion or iteration.
.data n: .word 8 .text main: la t0, n lw a0, 0(t0) jal ra, factorial addi a1, a0, 0 addi a0, x0, 1 ecall # Print Result addi a0, x0, 10 ecall # Exit factorial: # YOUR CODE HERE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
