Question: Part1 Write an assembly program to count how many even numbers and how many odd numbers in a given array. Use the following array or

Part1

Write an assembly program to count how many even numbers and how many odd numbers in a given array. Use the following array or your own array. Must use Bit Condition Branch Instructions (BRCLR and/or BRSET)

10, 22, 11, 54, 3, 17, 39, 91, 16, 88, 15, 77, 51, 33, 47, 88

Use the following memory addresses:

Address $800 to store the count ( number of data points in the array)

Address $802 to store the number of ODD numbers in the array

Address $804 to store the number of EVER numbers in the array

Store your array in the RAMStart:

ORG RAMStart

Data: DC.B 10, 22, 11, 54, 3, 17, 39, 91, 16, 88, 15, 77, 51, 33, 47, 88

Take a snap shot of the memory locations starting at $800 (This section of memory should show the total number of data points in the array, the total number of even numbers and the total number of even numbers. Make a visual comparison between the results of your program and the given array to check the correctness.

IV. Part 2 procedure:

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.

Copy and paste the source code.

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.

IV. 2.A. Copy and paste the source code.

IV. 2. B. Copy and paste the assembly, register, and memory after the first JSR instruction to verify that stack holds the return address.

IV. 2. C Copy and paste the memory window to show the values of Sum1 and Sum2.

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 Databases Questions!