Description of this paper

Week 3- ECET 330- Microprocessor. Devry University




1. Write a program to find the sum of the elements of an array called list1. The size of list1 is four bytes. The values of list1 are $FF, $1, $FE, and $02. To check your work, the sum should become $0200.;The requirements for writing this program are as follows.;-You must use a loop and count variable (i.e. count must be defined in the data section) as a loop counter.;- Clear both Registers A and B using CLRA and CLRB instructions.;-Use indexed addressing mode to access the elements of the array using Register X as the index register. The instruction LDX #list1 places the array list1 address into Register X.;-Add each element to Register B.;-Use the branch instruction BCC to check if there is a carry after the addition of each element. BCC means the Branch if Carry flag is clear.;-If there is a carry, add 1 to Register A.;-The final result should be in Register A and B.;A. Copy and paste the register window at the second iteration where the carry becomes set. Highlight the carry flag to show that it is set.;B. Copy and paste the register window to show the final result.;2. Write a program to use a subroutine to find the sum of the array elements. For simplicity, assume that the sum of the data values is less than $FF. You do not need to use the BCC to check for carry flag. Follow the following steps to write this program.;- Define two arrays called List1 and List2 using DC.B directive. Initialize List1 with byte-size values of $6, $12, $4, $0F, and $11. Initialize List2 with byte-size values of $4, $5, and $7. Reserve two byte-size locations called Sum1 and Sum2 using DS.B directive.;- The subroutine must find the sum of the elements of the array list1. Before calling the subroutine, the main program must initialize Register X to have the address of the array and Register B to have the size of the array.;- The subroutine must use a loop and indexed addressing mode using Register X as the index register and Register B as the loop counter. The subroutine must return the sum in Register A.;- The main program must call the subroutine two times. The first time, the subroutine will find the sum of the array List1. After returning from the subroutine, the main code must save Register A in Sum1. Then, the subroutine is called for a second time to find the sum of the elements in List2. After the return from the subroutine, the value of Register A is saved in Sum2.;- Since this code is using a subroutine, make sure to initialize the SP register using;LDS #$4000.;This line must be added to the main code before calling any subroutines.;A. Copy and paste the source code.;B. Copy and paste the assembly, register, and memory after the first JSR instruction to verify that stack holds the return address.;C. Copy and paste the memory window to show the values of Sum1 and Sum2.


Paper#66560 | Written in 18-Jul-2015

Price : $27