Question: . data result: . word 0 prompt: . asciz Enter a number ( 0 - 5 ) : output: . asciiz The factorial is:
data
result: word
prompt: asciz "Enter a number :
output: asciiz "The factorial is:
text
globl main
main:
Ii $v
la $a prompt
syscall
li $v
syscall
move $t $t
beqz $t factorialzero
li $ t#
beq $t $t factorialone
li $t
beq $t factorialtwo
beq $ factorial three
beq $t factorialfour
beq $ factorialfive
J exit
factorialzero:
li $t
j storeresult
factorialone:
li $t
j storeresult
factorialtwo:
li $t
j storeresult
factorialthree:
li $t
j storeresult
factorialfour:
li $t
j storeresult
factorial five:
li $t
j storeresult
Storeresult:
sw $t result
# Print the result
li $v
la $a output
syscall
Iw $a result
li $v
syscall
exit:
li $v
syscall
Explain every line of code and what it does. If any mistakes fix them please. Would also like the output of the code. Will give a thumbs up
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
