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
Assembly and Embedded Programming
Fall
Homework Three
This problem explores two strategies for accessing the elements of an array to implement the
following loop expression, where R refers to the CPU register R R refers to the CPU
register R and Array is an array of byte values allocated in memory.
for ;;
Array
a Write an assembly language code fragment to implement the loop expression as follows.
Use a conditional branch instruction, ie Bcond for loop control.
Use indexed mode addressing to access the array: RBase RIndex
Use one register to hold the base, ie 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, ie Bcond for loop control.
Use displacement mode addressing to access the array, where the displacement is
such that there is effectively register indirect mode addressing: RIndirect #
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 R
Accepts a word value in register R which indicates the number of array elements.
Returns the total, ie 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: R #
Manually update the array pointer to access the next element: ADDS R
Use a down counter to control iteration count from R down to
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 R down to
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
