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

Write the LEGv8 assembly for the following code snippet (assuming the base addre

ID: 3877945 • Letter: W

Question

Write the LEGv8 assembly for the following code snippet (assuming the base address of A is in X9, the base address of B is in X10, i is in X11 and j is in X12 and that A and B store 64-bit integer values): A[i] = B[j]; NOTE: There should be no extraneous spaces in your answers, and all instructions and register characters should be capitalized. Commas are used appropriately to separate instruction arguments with a single space after. Instruction Description / Comments Compute offset of element j putting the result in register X13 Compute absolute address of B, element j putting the result in register X13 Move B, element j from memory into register X13 Compute offset of element i putting the result in register X14 Compute absolute address of A, element i putting the result in register X14 Move the value from register X13 into A, element i in memory

Explanation / Answer

Given:

Base A = X9

Base B = X10

A index (i) = X11

B index (j) = X12

Instruction Description

LSL X13, X12 , #3 calculating offset of element j

ADD X13, X13 , X10 calculating Absolute address of B[j]

LDUR X13,[X13,#0] moving B[j] from memory into X13

LSL X14, X11 , #3 calculating offset of element i

ADD X14, X14 , X9 calculating Absolute address of B[j]

STUR X13,[X14,#0] moving B[j] from memory into X13