Answered step by step
Verified Expert Solution
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)
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started