COMP 2033, Spring 2018 Homework2 Instructor: Dr. Ahmed A. Ahmed Due: 03/20/2018
ID: 3734043 • Letter: C
Question
COMP 2033, Spring 2018 Homework2 Instructor: Dr. Ahmed A. Ahmed Due: 03/20/2018 at 11:55 PM (sharp!) Marks: 100 points Submission Instructions: 1. Upload your.asm files to eCourse in a zip file 2. Please include a readme file that has (i) your name and student ID; and (ii) detailed instructions on how to run your programs. 3. Must receive instructor's approval in advance if an alternative time and method of submission becomes necessary. Solve each of the following problems. To receive full marks on your documentation, you should have excellent internal documentation (i.e., appropriate comments, but also choice of variable names), as well as excellent external documentation (i.e., in the readme.txt file as described previously) [70 points] Write an assembly program to compute the nth number in the Fibonacci series The first and second Fibonacci numbers are 0 and 1, respectively. Every subsequent Fibonacci numbers are the sum of the previous two Fibonacci numbers. For example, the third Fibonacci number is 1 (ie., 0 + 1), the fourth is 2 (ie., l +1), the fifth is 3 (i.e., l+2), and so on. The program must use a loop to compute Fibonacci numbers and display their values on the screen. Display the first 10, 15 and 20 numbers as test cases 1. [30 points] Extend your solution to Problem 1 so that instead of displaying the list in the increasing order, the program shows the Fibonacci numbers in reverse order. Particularly, after constructing the original list, initialize another list with the same size in which y build the contents of this list from the original one in the reverse order. 2. ouExplanation / Answer
I think this is an academic assignment so I'm going to partially answer the question.
The fibonacci sequence is for non-negative integers as follows:
The below logic will cmputes for the nth value of the fibonacci in the series,
This gives:
You can do it with just a few registers, let's identify them:
Rn is passed as the argument to the function. Rf1 shall start at 0, and Rf2 shall start at 1.
Here's what we do to get the answer, split up by routines:
Begin
Loop
Finish
FinishEven
Tracing through for Rn = 5:
Our table shows that F(5) = 5, so this is correct.
The below code will displays the fibonacci series in the reverse order,
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.