Question: You are to design, write, assemble, and simulate an assembly language program which will generate the Nth number in the Fibonacci sequence. This is a
You are to design, write, assemble, and simulate an assembly language program which will generate the Nth number in the Fibonacci sequence. This is a motorola 68HC11 microcontroller
For this lab, N again is a 1 byte unsigned integer. However, the result is stored as a 4-byte number in RESULT in BIG ENDIAN format
For example, if N = 40, your answer should be $06197ECB.
This is what I have so far and I seem to be getting only a 2 byte variable, help please * Pseudocode: * unsigned int N = 10; (1 byte variable) * unsigned int RESULT; (2-byte variable) * * unsigned int COUNT; (1 byte variable) * unsigned int PREV; (2-byte variable) * unsigned int NEXT; (2-byte variable) * * * RESULT=1; * PREV=1; * COUNT = N; * while(COUNT>2){ * NEXT = RESULT + PREV; * PREV = RESULT; * RESULT = NEXT; * COUNT--; * } *
* start of data section
ORG $B000 N FCB 25
ORG $B010 RESULT RMB 2
* define any other variables that you might need here
COUNT RMB 1 PREV RMB 2 NEXT RMB 2
* start of your program ORG $C000 LDD #1 STD RESULT RESULT = 1 STD PREV PREV = 1 LDAA N STAA COUNT COUNT = N WHILE LDAA COUNT CMPA #2 while(COUNT>2){ BLS ENDWHILE LDD RESULT ADDD PREV STD NEXT NEXT = RESULT + PREV; LDD RESULT STD PREV PREV = RESULT; LDD NEXT STD RESULT RESULT = NEXT; DEC COUNT COUNT--; BRA WHILE } ENDWHILE DONE BRA DONE END
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
