Write a recursive function in MIPS to compute factorial of a user entered integer.

Question Description

Write a recursive function in MIPS to compute factorial of a user entered integer. You must submit code and screenshot of output in a single word or pdf document.note that you must write a recursive procedure for the third assignment, and not a loop to compute factorial.

Final Answer


subu $sp, $sp, 4 

sw $ra, 4($sp) # spare the profit address for stack 

beqz $a0, end # test for end 

subu $sp, $sp, 4 # don't end yet 

sw $a0, 4($sp) # save the parameter 

sub $a0, $a0, 1 # will call with a littler contention 

jal Factorial 

# after the end condition is arrived at these lines 

# will be executed 

lw $t0, 4($sp) # the contention I have saved money on stack 

mul $v0, $v0, $t0 # do the duplication 

lw $ra, 8($sp) # plan to return 

addu $sp, $sp, 8 # I've popped 2 words (a location and 

jr $ra # .. a contention) 


li $v0, 1 # 0! = 1 is the return esteem 

lw $ra, 4($sp) # get the return address 

addu $sp, $sp, 4 # modify the stack pointer 

jr $ra # return

salamatshah (270)
UT Austin

The tutor managed to follow the requirements for my assignment and helped me understand the concepts on it.

The tutor was knowledgeable, will be using the service again.

Awesome quality of the tutor. They were helpful and accommodating given my needs.


Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors