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

label Computer Science
account_circle Unassigned
schedule 1 Day
account_balance_wallet $5

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.

Mar 16th, 2015

Factorial: 

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) 

end: 

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

Mar 16th, 2015

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Mar 16th, 2015
...
Mar 16th, 2015
Sep 21st, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer