You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
562 B
42 lines
562 B
.text |
|
main: |
|
# Prompt user to input non-negative number |
|
la $a0,prompt |
|
li $v0,4 |
|
syscall |
|
|
|
li $v0,5 #Read the number(n) |
|
syscall |
|
|
|
move $t2,$v0 # n to $t2 |
|
|
|
# Call function to get fibonnacci #n |
|
move $a0,$t2 |
|
move $v0,$t2 |
|
jal fib #call fib (n) |
|
move $t3,$v0 #result is in $t3 |
|
|
|
# Output message and n |
|
la $a0,result #Print F_ |
|
li $v0,4 |
|
syscall |
|
|
|
move $a0,$t2 #Print n |
|
li $v0,1 |
|
syscall |
|
|
|
la $a0,result2 #Print = |
|
li $v0,4 |
|
syscall |
|
|
|
move $a0,$t3 #Print the answer |
|
li $v0,1 |
|
syscall |
|
|
|
la $a0,endl #Print '\n' |
|
li $v0,4 |
|
syscall |
|
|
|
# End program |
|
li $v0,10 |
|
syscall
|
|
|