Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.Writing the Code 2.1 To get you started, here is a template for the assembly program that you should write: n = 8, calculate fib(s)

image text in transcribed

2.Writing the Code 2.1 To get you started, here is a template for the assembly program that you should write: n = 8, calculate fib(s) in this lab main: addi sao, $0, addi $t0,$0,-1 addi $t1,$0,1 loop: beg So, 0, j loop jump-start loop with fib-1) and fib (0) # done : j done Note: you do not need to use recursive program in this lab. Use Notepad (or your favorite text editor) to enter this code into a text file named lab_Fibonacci.com (where xx are your initials). Fill in the missing lines of code to complete the loop that computes fib(n). You should be able to do this in fewer than 10 lines of code Remember that SUB does not take a constant operand. However, you may subtract a constant by using ADDI with a negative value. Note that the first line of code places the value $ into register A0. This is the n argument to the fib function. You should test your program on several different values (not just 8). The third and fourth lines of code load the values of fib(-1) and fib(0) into registers TO and Tl, respectively. As mentioned above, these can be used to "boot-strap" your loop. After looping the number of times specified by the value placed in register A0, your code should leave the resulting value of fib(n) in register Sv0 and branch to done. The last line of code is simply a way of ensuring that your program terminates in a predictable manner. Comments begin with the '#' character and continue to the end of the line. Test your program on several different values like 4, 5 and 8, observe that Sto. Stlwill change exactly as that in the above table. 2.Writing the Code 2.1 To get you started, here is a template for the assembly program that you should write: n = 8, calculate fib(s) in this lab main: addi sao, $0, addi $t0,$0,-1 addi $t1,$0,1 loop: beg So, 0, j loop jump-start loop with fib-1) and fib (0) # done : j done Note: you do not need to use recursive program in this lab. Use Notepad (or your favorite text editor) to enter this code into a text file named lab_Fibonacci.com (where xx are your initials). Fill in the missing lines of code to complete the loop that computes fib(n). You should be able to do this in fewer than 10 lines of code Remember that SUB does not take a constant operand. However, you may subtract a constant by using ADDI with a negative value. Note that the first line of code places the value $ into register A0. This is the n argument to the fib function. You should test your program on several different values (not just 8). The third and fourth lines of code load the values of fib(-1) and fib(0) into registers TO and Tl, respectively. As mentioned above, these can be used to "boot-strap" your loop. After looping the number of times specified by the value placed in register A0, your code should leave the resulting value of fib(n) in register Sv0 and branch to done. The last line of code is simply a way of ensuring that your program terminates in a predictable manner. Comments begin with the '#' character and continue to the end of the line. Test your program on several different values like 4, 5 and 8, observe that Sto. Stlwill change exactly as that in the above table

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

Step: 3

blur-text-image

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

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions