Question: You are to design, write, assemble, and simulate an assembly language program which will generate sum of integer squares numbers. Giving is an array NARR
You are to design, write, assemble, and simulate an assembly language program which will
generate sum of integer squares numbers. Giving is an array NARR of bytelong numbers with a
$FF sentinel Each element in the table corresponds to the end value N of the sum of squares to
be generated as defined in Lab The actual calculation of the corresponding byte sum of
integer squares has to be implemented in a subroutine. The byte sum has to be passed back to
the main program, which stores it consecutively in the RESARR array.
PLEASE NOTE:
The complete sum calculation has to be done in the subroutine using the algorithm defined in
Lab resulting in two nested loops, inside a single subroutine. Using any other algorithm,
implementation, multiplication, or the MUL instruction 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
Your program is NOT allowed to change the numbers stored in NARR.
All multibyte data items are in Big Endian format including all program variables
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 memory locations variables are stored ie $B for NARR and $B
for RESARR 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 program or algorithm 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
The main program should be a WHILE structure which goes through the NARR 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 RESULT
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 RESULT 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 for any sentinel value, not just $FF
For each iteration, the main program should take a number from the NARR table and pass it
to the subroutine in a register callbyvalue in register The subroutine performs the sum
calculation and produces a byte result. This result byte must be passed back to the main
program OVER THE STACK callbyvalue over the stack The main program then
retrieves the four bytes from the stack and stores it in the RESULT 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 errorwarning messages appearing when assemblingsimulating
your submitted program will result in up to points lost.
NOTE # ONLY LOCAL VARIABLES ARE ALLOWED LOCAL TO THE MAIN PROGRAM AND THE SUBROUTINE INSIDE THE SUBROUTINE YOU CAN ONLY ACCESS LOCAL VARIABLES AND ITEMS PASSED IN FROMTHE MAIN PROGRAM!! YOU MUST NOT ACCESS MAIN PROGRAM VARIABLES SU
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
