Answered step by step
Verified Expert Solution
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 bytelong 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 The byte factorial has to be passed back to the main program, which stores it in the NFAC
array.
PLEASE NOTE:
The complete factorial calculation has to be done using the algorithm defined in Lab inside a single
subroutine. Using any other algorithm or implementation instead is NOT allowed and will result in
lost points.
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
You are NOT allowed to use the MUL instruction anywhere in your program.
Your program is NOT allowed to change the numbers stored in the N table.
You have to use the program skeleton provided for Lab Do not change the data section or you will lose
points! This means: do not change the 'ORG $B and 'ORG $B statements or the variable names
N and NFAC If you need to define additional variables, please add them in the appropriate places.
You are allowed to use parts of your LAB or parts of the official LAB solution.
You are allowed to declare static variables in your subroutine through RMB FCB FDB
Your subroutine should only have one exit point. This means that only a single RTS instruction at the
end of the subroutine is allowed.
You must terminate your program correctly using the STOP instruction.
The main program must only have one exit point ie only one STOP instruction at the end of the main
program is allowed
You do not have to optimize your algorithm or your assembly program for speed.
You have to provide a pseudocode solution for your main program AND your subroutine. In your
pseudo codes, do NOT use a for loop, but either a while or a dountil structure to implement a loop. Also,
do NOT use any gotobreak or exit statements in your pseudo codes. The structure of your
assembly program should match the structure of your pseudo codes to
In the assignment, under item there are a couple of typos. It should be:
For each subroutine call, the subroutine will send back a 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 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 elements in the tables. Using the Bregister as an array index and the
ABXABY instructions add this index to the pointers will therefore not work.
Your program should work with any sentinel value, not just $FF
For each iteration, the main program should take a number from the N table and pass it to the subroutine
in a register callbyvalue in register The subroutine performs the factorial calculation and produces
a byte result. These result bytes must be passed back to the main program OVER THE STACK call
byvalue 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 Lab
Do not try to access values in a region of the stack that has already been closed.
Preparation of parameter passing back to the main program ie opening hole on the stack for the
parameter needs to be done in the subroutine, not in the main program.
Any assembler or simulator error messages appearing when assemblingsimulating your submitted
program will result in up to points lost.
USE the skeleton to outline the code and use the C program ONE TO ONE while coding in the MOTOROLLA HC 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started