Question: CMPE - 2 5 0 Assembly and Embedded Programming Fall 2 0 2 4 Homework Three This problem explores two strategies for accessing the elements

CMPE-250
Assembly and Embedded Programming
Fall 2024
Homework Three
This problem explores two strategies for accessing the elements of an array to implement the
following loop expression, where R0 refers to the CPU register R0, R1 refers to the CPU
register R1, and Array is an array of byte values allocated in memory.
R0=0
for =(R1=0;R1100;R1++)
R=R0+ Array[R1]
a. Write an assembly language code fragment to implement the loop expression as follows.
Use a conditional branch instruction, (i.e., Bcond), for loop control.
Use indexed mode addressing to access the array: [RBase, RIndex].
Use one register to hold the base, (i.e., starting), address of each array.
Use another register to hold the index of the element being accessed.
b. Write an assembly language code fragment to implement the loop expression as follows.
Use a conditional branch instruction, (i.e., Bcond) for loop control.
Use displacement mode addressing to access the array, where the displacement is 0
such that there is effectively register indirect mode addressing: [RIndirect, #0]
Use one register to hold the address of the array element being accessed.
This problem explores two strategies for sequentially accessing the elements of a word array
to implement an assembly language subroutine Total according to these specifications.
Accepts a pointer to an array of signed words in register R1.
Accepts a word value in register R2, which indicates the number of array elements.
Returns the total, (i.e., sum), of array elements in register RO.
On return, preserves contents of all registers, other than return result register and PSR.
a. Write an assembly language subroutine to implement Total as follows.
Use displacement mode addressing to access each element: [R1, #0].
Manually update the array pointer to access the next element: ADDS R1,....
Use a down counter to control iteration (count from R2 down to 0).
b. Write an assembly language subroutine to implement Total as follows.
Use the autoincrement form of load multiple LDM to access each array element and
update the array pointer in one instruction.
Use a down counter to control iteration (count from R2 down to 0).
CMPE - 2 5 0 Assembly and Embedded Programming

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!