EMBEDDED:
Write a program in ARM assembly language that copies each element of array A to consecutive fourth elements of array B, i.e., A[0] to B[0], A[1] to B[3], A[2] to B[7], etc. The array A is 12 elements long, and each element is a number that is 32 bits (1 word) wide. Assume the base address of array A is in register R2, and the base address of array B is in R3.
Answer : Given data
* The program in ARM assembly language that copies each element of array A to consecutive fourth elements of array B, i.e., A[0] to B[0], A[1] to B[3], A[2] to B[7], etc
The required program snippet for the above operation in ARM assembly with R2 as base address of array A snd R3 as base address of array B is as below.
* MOV R4,#0 ; initialise loop counter
* LOOP LDR R5,[R2],#4 ;load the word content 32bit array A element to R5 register and post increment R2 to point to nextvelement of array A
* STR R5,[R3],#16 ;Store the word content 32bit into array B element from R5 register and post increment R3 to point to next 4th consicutive element of array B
* ADD R4,R4,#1 ; increment loop counter
* CMP R4,#12 ; checking condition for 12 elements
* BNE LOOP ; repeats loop for 12 times till r4 is 12\
___________THE END_____________
Get Answers For Free
Most questions answered within 1 hours.