Question: I need some help with this assignment here, I mainly need help with the last bolded statement. Write a program in assembly language using the

I need some help with this assignment here, I mainly need help with the last bolded statement.

Write a program in assembly language using the MIPS instruction set to calculate the nth Fibonacci number. This must be done in an iterative loop. Your program will read from input the value of n. Be sure to validate user input and report errors when necessary. n must be a natural number that can not be too large that the value of f(n) cannot be expressed with a 32-bit unsigned integer and can be output to the console in SPIM. While iterating through this loop, store the value of f(n) in an array. Ths array should be large enough to contain N values (where N is the largest permissible value of n.) Your program should then output the nth Fibonacci number then output the portion of the sequence stored in the array.

here is what I have so far

*******************************************************************

.data

msg: .asciiz "Enter integer: " #display message

msg2: .asciiz "The Fibonacci number is: " #display output message

checkmsg: .asciiz " Input is too large " #validation message

arr: .space 1000 #creating space for array

.text

.globl main

main:

la $a1, arr

li $s2, 0

li $s3, 0

li $s4, 1

li $a0, 0

addu $t5, $zero, 4294967295

input:

la $a0, msg #display message

li $v0,4

syscall

li $v0,5 #read input

syscall

addi $s1, $v0,0 #store input

fib:

addi $s2, $s2, 1

add $s5, $s3, $s4

addi $s4, $s3, 0

addi $s3, $s5, 0

bne $s2, $s1, fib

validate:

sltu $s0,$s5,$t5

beq $s0, $zero, error

la $a0, msg2 #display message2

li $v0,4

syscall

li $v0, 1 # print fib

addi $a0, $s5,0

syscall

end:

li $v0 , 10

syscall

error:

la $a0, checkmsg

li $v0, 4

syscall

li $v0, 10

syscall

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!