Question: Write a Z 8 0 assembly language program which computes the first 2 1 values in the Fibonacci sequence. Recall that the Fibonacci sequence is
Write a Z assembly language program which computes the first values in the Fibonacci sequence. Recall that the Fibonacci sequence is defined as follows: ; add setup and initial statement for inner Fibonacci function loop here
innerloop:; finally load result to "result" variable for printing when inner loop is finishedprintresult:call BD ; convert variable value to number stringld hl NEWLINE ; start HL at newlineld ; increment nld n adec bc ; decrement main counteror chaltprint:
orint: or a ; has null terminator been reached?push hl ; push HL to stack will be changed by PRNCHRpop hl ; pop HL from stackjr print ; repeatSTRBANNERLABELbyte ; ZeroFill Remainder of Cartridge ROM #include "equ.asm" byte CS Lab #Summer
F; F; Fn Fn Fn for n
As you may recall from your earlier programming classes, this is a recursive definition that is expressed in terms of itself. It also clearly states the base cases; in this case, n and n An iterative implementation of this function, written as it might appear in a CC or Java program, is shown below:
public int fibint n
int current ;
int next ;
int nextnext ;
for int i ; i n; i
nextnext current next;
current next;
next nextnext;
return current;
Using the attached LABasm program file as a starting point, and following the iterative implementation shown above, implement an algorithm in Z assembly language to produce the first values in the Fibonacci sequence from n to n
The output of your completed program should show the following:
CS Lab #Summer
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
Look for the INSERT YOUR CODE HERE comment block in the program file, starting on Line ; this is where you should begin adding your instructions to complete the program. The other code already provided in the file should not be changed.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
