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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!