Review

ECE222 k = A[5] A[5] = j ; is a store word since A is in the memory

  • write RV64I asembly for this. Assuming the base address of an array of words, A[], is stored in x22. Also j,k variables are stored in x1, x2 respectively.

lw x2, 20 (x22) sw x1, 20 (x22)

  • write code also for j = A[i], where i is in register x5:
slli x6, x5, 2 ; i *4
add x6, x6, x22 ; base address + i*4
lw x1, 0 (x6)