Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to design, write, assemble, and simulate an assembly language program which will calculate the factorial of byte - long unsigned numbers stored in

You are to design, write, assemble, and simulate an assembly language program which will calculate the
factorial of byte-long unsigned numbers stored in a table N (with a $FF sentinel), and will store the factorial
in an array NFAC. The actual factorial calculation has to be implemented in a subroutine using the algorithm
from lab 3. The 2-byte factorial has to be passed back to the main program, which stores it in the NFAC
array.
PLEASE NOTE:
1. The complete factorial calculation has to be done using the algorithm defined in Lab3 inside a single
subroutine. Using any other algorithm or implementation instead is NOT allowed and will result in 50
lost points.
2. Your program should work for any N value, not just the ones given in the table. Also, it should work for
any sentinel value, not just for $FF.
3. You are NOT allowed to use the MUL instruction anywhere in your program.
4. Your program is NOT allowed to change the numbers stored in the N table.
5. You have to use the program skeleton provided for Lab4. Do not change the data section or you will lose
points! This means: do not change the 'ORG $B000' and 'ORG $B010' statements or the variable names
N and NFAC. If you need to define additional variables, please add them in the appropriate places.
6. You are allowed to use parts of your LAB3 or parts of the official LAB3 solution.
7. You are allowed to declare static variables in your subroutine (through RMB, FCB, FDB).
8. Your subroutine should only have one exit point. This means that only a single RTS instruction at the
end of the subroutine is allowed.
9. You must terminate your program correctly using the STOP instruction.
10. The main program must only have one exit point (i.e., only one STOP instruction at the end of the main
program is allowed).
11. You do not have to optimize your algorithm or your assembly program for speed.
12. You have to provide a pseudo-code solution for your main program AND your subroutine. In your
pseudo codes, do NOT use a for loop, but either a while or a do-until structure to implement a loop. Also,
do NOT use any goto,break, or exit statements in your pseudo codes. The structure of your
assembly program should match the structure of your pseudo codes 1-to-1.
13. In the assignment, under item 13, there are a couple of typos. It should be:
... For each subroutine call, the subroutine will send back a 2-byte result that has to be stored consecutively in the NFAC table. ..
You dont have to copy the sentinel to the end of the NFAC array. The main program should be a WHILE structure which goes through the N table and sends the value to
the subroutine during each iteration. The while structure will also check for the Sentinel (which is the
$FF at the end of the tables) at each iteration. The Sentinel is NOT one of the data items and it should
NOT be processed by the subroutine. The main program must end the while loop when the $FF is
encountered. For each subroutine call, the subroutine will send back a 2-byte result that has to be stored
consecutively in the NFAC table.
You are not allowed to just manually count the number of elements in the table and set up a
fixed number in memory as a count variable.
Your program should still work if the arrays are moved to different places in memory (do not
use any fixed offsets).
You dont have to copy the sentinel to the end of the NFAC array.
Your program should work for any number of elements in the table. Thus, there could be
more than 255 elements in the tables. Using the B-register as an array index and the
ABX/ABY instructions add this index to the pointers will therefore not work.
Your program should work with any sentinel value, not just $FF.
14. For each iteration, the main program should take a number from the N table and pass it to the subroutine
in a register (call-by-value in register). The subroutine performs the factorial calculation and produces
a 2-byte result. These result bytes must be passed back to the main program OVER THE STACK (call-
by-value over the stack). The main program then retrieves the bytes from the stack and stores it in the
NFAC array.
Make sure that your program will not generate a stack underflow or overflow.
ALL of the number processing must be done inside a single subroutine using the algorithm
from Lab3.
Do not try to access values in a region of the stack that has already been closed.
15. Preparation of parameter passing back to the main program (i.e., opening hole on the stack for the
parameter) needs to be done in the subroutine, not in the main program.
16. Any assembler or simulator error messages appearing when assembling/simulating your submitted
program will result in up to 25 points lost.
USE the skeleton to outline the code and use the C program ONE TO ONE while coding in the MOTOROLLA 68HC11 as well as implement the same algorithm for factorial calculation as in the completed assembly code.AND PLEASE TEST THE PROGRAM WITH SOMETHING LIKE WOOKIE
image text in transcribed

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

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions