Question: . text main: li $a 0 , 5 hardcode factorial ( 5 ) jal factorial move $a 0 , $v 0 # copy return from
text
main: li $a hardcode factorial
jal factorial
move $a $v # copy return from factorialk into argument
li $ # integer print $ with syscall
syscall
exit: li $ # exit with syscall
syscall
# subroutine FACTORIAL
# calculates
#IN: $ as unsigned integer
# OUT: $ FACTORIAL
# CHANGES: $t $t $v
factorial:
bne $ zero, nonzero # special case
li $ # same as FACTORIAL
nonzero:
move $t $a #t a
addi $t $t# t for comparison
li $t # counter
li $v # result
loop: mul $$$#
addi $$#
bne $$ loop
$
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
