Hi I need help with my assignment. I have almost completed bit my program has to return -1 if th euser eners a non numeric value, which I have problem with.
here is my ass
Create a small program that takes number as an input and prints the factorial of that number.
ü If the input is non numeric then print -1
ü If the number is negative print -1
ü The number range should be between 0 and 30
here is my code
.data
prompt: .asciiz"\nEnter an positive integer less than 30: "
prompt1: .asciiz"\n -1"
.text
.globl main
main:
li $v0, 4
la $a0, prompt
syscall
li $v0,5
syscall
move $a0, $v0
move $t1,$a0
blt $t1, 0, output1
bgt $t1, 30, output1
jal check
output1:
li $v0, 4
la $a0, prompt1
syscall
exit:
jr $ra
check:
mul $t3, $t1,1
bne $a0, $zero, fac
fac:
mul $t2, $t3, 1
sub $t1, $t1, 1
blt $t1, 1, output
jal multiplication
multiplication:
mul $t3,$t2,$t1
jal fac
output:
move $a0, $t3
li $v0, 1
syscall