Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to calculate the nth number of a Fibonacci sequence in 4 bytes using a subroutine. It has to be done on a Motorola

I need to calculate the nth number of a Fibonacci sequence in 4 bytes using a subroutine. It has to be done on a Motorola 68HC11 microcontroller.

This is the pseudocode I have without the subroutine, the skeleton is below it. I hope someone can help, please!

*************************************************************************************************************************************

* Pseudocode: * * unsigned int N=40 * unsigned int RESULT (4-byte variable) * unsigned int PREV (4-byte variable) * unsigned int NEXT (4-byte variable) * unsigned int COUNT (1-byte variable) * * * RESULT=1; * PREV=1; * COUNT = N; * while(N>2){ * NEXT(lower two bytes) = RESULT (lower two bytes)+ PREV (lower two bytes); * NEXT(upper two bytes) = RESULT (upper two bytes); * if( C-flag ==1) NEXT(upper two bytes) ++; * NEXT(upper two bytes) += PREV (upper two bytes); * * (the above implements a 4-byte addition using two 2-byte additions) * * PREV(upper two bytes) = RESULT (upper two bytes); * PREV(lower two bytes) = RESULT (lower two bytes); * * RESULT(upper two bytes) = NEXT (upper two bytes); * RESULT(lower two bytes) = NEXT (lower two bytes); * * N--; * } * }

********************************************************************************

This is the Skeleton on the assignment!

*start of data section

ORG $B000

NARR FCB 1, 2, 5, 10, 20, 128, 254, 255, $00

SENTIN EQU $00

ORG $B010

RESARR RMB 32

* define any variables that your MAIN program might need here

* REMEMBER: Your subroutine must not access any of the main

* program variables including NARR and RESARR.

ORG $C000

LDS #$01FF initialize stack pointer

* start of your main program

* define any variables that your SUBROUTINE might need here

ORG $D000

* start of your subroutine

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

Students also viewed these Databases questions

Question

what is the gravetational potential energy of a steel sphere

Answered: 1 week ago