Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

# https://oeis.org/A000045/b000045.txt gives me a list of first 2000 Fibanocci numbers .data n: .word 2 .text main: la $s0,n lw $a0, 0($s0) jal fib #

# https://oeis.org/A000045/b000045.txt gives me a list of first 2000 Fibanocci numbers

.data

n: .word 2

.text

main: la $s0,n

lw $a0, 0($s0)

jal fib

# move what ever is returned into $a0

move $a0, $v0

li $v0,1

syscall

b finished

fib:

#li $t0,1 # Check for number 1 start my returns, special case

#beq $a0, $t0, return_1 #Not at end, call fib again.

#Check for value of 2

li $t0,2 # Check for 2 special case

blt $a0, $t0, return2 #Not at end, call fib again.

#Done with cases for 1 and 2, lets do it for all other numbers.

else: # Done with special cases, this is from GE 3

# Rest of the code to account for numbers GE 3

return_1:

#addi $v0, $0, 1 # yes : return 1

addi $v0,$zero,1 # vo will be 1 (Special case)

jr $ra # return to Main

return2:

addi $a1,$zero,1 #previous number is is 1 for special case

addi $v0,$zero,1 #current number is is 1 for special case

addi $a0,$a0 -1 # Decrement the counter

add $sp, $sp, -4 #make room for 2 registers on the stack.

sw $ra,0($sp) # store $ra on the stack

jal fib

lw $ra , 0($sp ) # restore restore restore $ra

addi $sp , $sp , 4 # restore restore restore $sp

jr $ra # return

finished:

please help me finish it thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students explore these related Databases questions