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 byte-long 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 Lab3). The actual calculation of the corresponding 4-byte sum of
integer squares has to be implemented in a subroutine. The 4-byte sum has to be passed back to
the main program, which stores it consecutively in the RESARR array.
PLEASE NOTE:
1. The complete sum calculation has to be done in the subroutine using the algorithm defined in
Lab3, 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 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. Your program is NOT allowed to change the numbers stored in NARR.
4. All multi-byte data items are in Big Endian format (including all program variables)
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 memory locations variables are stored (i.e., $B000 for NARR and $B010
for RESARR). 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 program or algorithm 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. 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 4-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 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 for any sentinel value, not just $FF.
14. For each iteration, the main program should take a number from the NARR table and pass it
to the subroutine in a register (call-by-value in register). The subroutine performs the sum
calculation and produces a 4-byte result. This result byte must be passed back to the main
program OVER THE STACK (call-by-value 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 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/warning messages appearing when assembling/simulating
your submitted program will result in up to 25 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
You are to design, write, assemble, and simulate

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!