Question: Write a MIPS assembly language program to calculate n! where n is 0=
Write a MIPS assembly language program to calculate n! where n is 0= here is what i have so far: .data str: .asciiz "Enter a number between 0 and 10 to calculate the factorial: " str2: .asciiz "The factorial of " str3: .asciiz " is:" new: .asciiz " " error: .asciiz "ERROR: NUMBER HAS TO BE BETWEEN 0 AND 10" error2: .asciiz "ERROR: NUMBER HAS TO POSITIVE" .text main: li $v0, 4 la $a0, str syscall li $v0, 5 syscall add $s1, $v0, $0 li $s2, 10 blt $s1, $0, nonPos bgt $s1, $s2, between li $t1, 1 li $v0, 10 syscall loop: beq $s1, $, j loop done: li $v0, 4 la $a0, new syscall la $a0, str2 syscall li $v0, 1 add $a0, $s1, $0 syscall la $a0, str3 syscall nonPos: li $v0, 4 la $a0, error2 syscall la $a0, new syscall j main between: li $v0, 4 li $a0, new syscall la $a0, error syscall j main
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
