Starting from:
$10

$4

PROGRAM #5 Solution

Write an ARM assembly program that will:




1. Call a copyArray subroutine that will copy the 64-bit integers in sourceArray into a 64-bit

destination array beginning at location 0x40000000, removing duplicate array entries in the process.

Hint: read a number from sourceArray and write it to the next available location in the destination

array if it is new. If the number is already in the destination array, ignore it. Both arrays are of

type DCQ. (The DCQ directive allocates one or more eight-byte blocks of memory, aligned on

four-byte boundaries, and defines the initial runtime contents of the memory.) You must pass the

address of the source array, the number of elements in the source array, and the address of the

destination array to the copyArray subroutine using a full descending stack. When called, the

copyArray subroutine will first push the return address onto the stack and then retrieve the three

parameters from the stack. When finished, copyArray will return control to the calling subroutine

by popping the return address into the program counter. The number of elements in the destination

array are to be returned in r0.




2. Call a sumArray subroutine that will sum the 64-bit integers in the newly created destination array.

You must pass the address of the destination array and the number of elements in the destination

array on the stack. The sumArray subroutine will first push the return address onto the stack and

then retrieve the two parameters from the stack. When finished, the sumArray subroutine will return

control to the calling subroutine, passing back the 64-bit sum in registers r0 and r1.

R0 will contain the most significant 32-bits and r1 the least significant 32-bits.




Initialize the stack pointer to 0x40000200. Submit your .s file (that is the file containing your source

code) through Canvas. Be sure to follow the programming guidelines. Late programs will not be accepted.




sourceArray

DCQ 0x0200200AD00236DD

DCQ 0x00003401AAC4D097

DCQ 0x0200200AD00236DD

DCQ 0x00010AA0AD3C66DF

DCQ 0x0000FC3D76400CCB

DCQ 0x000090045ACDD097

DCQ 0x00000FF000004551

DCQ 0x0200200AD00236DD

DCQ 0x003AC401AAC4D097

DCQ 0x000090045ACDD097

DCQ 0x09990AA0AD3C66DF

DCQ 0x1000200AD00236DD

DCQ 0x00003401AAC4D097

DCQ 0x000001102ACFF200

DCQ 0x00010AA0AD3C66DF

DCQ 0x003AC401AAC4D097

DCQ 0x1000FC3D76400CCB

DCQ 0x000090045ACDD097

DCQ 0x00000FF000004551

DCQ 0x00000000003C66DF

DCQ 0x0200200AD00236DD

DCQ 0x00003401AAC4D097

DCQ 0x000001102ACFF200

endArr

tsize EQU ((endArr-sourceArray)/8)

More products