Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The solution of the assembly code is included. Can someone explain how the resul

ID: 3349717 • Letter: T

Question

The solution of the assembly code is included. Can someone explain how the result is acquired? How does 20 relate to 5 in the array? Please explain. Thanks.

Problem 6. Assembly coding [15 points Assume an array of 25 integers (each integer is a word, i.e. 4 bytes). A compiler associates variables x and y with registers ro and r1, respectively. Assume that the base address for the array is located in register r 1 Translate this C statement into ARM assembly language x array[5] +y LDR, R1, [R2, 201 ADD R1, R1, RO (5 points)

Explanation / Answer

As you mentioned each integer is a word i.e. 4 bytes so array[5] means sixth integer and which is located after 19th byte.

{ (0-3) 1st integer

(4-7) 2nd integer

(8-11) 3rd integer

(12-15) 4th integer

(16-19) 5th integer }

So 20th byte which is start of 6th integer which is in c array[5]. This way 20 related to 5 in the array.

in the first statement LDR, R1,[R2.20] loads x=array[5]

in the second statement ADD R1,R1,R0 adds x=x+y : x=array[5]+y