0 votes
in General Knowledge by (773k points)
How do you write the following expressions in X86-64? (assime array is of ints, or 4 byte values)
E
E[i]
&(E[i])
E+i-1
*(E+i-3)

Suppose rdx holds starting address of array E & rcx holds integer index i

1 Answer

0 votes
by (773k points)
 
Best answer
E - movq %rdx, %rax (address copy)
E[i] - mov1 (%rdx, %rcx, 4), %eax (reference memory)
&(E[i]) - leaq (%rdx, %rcx, 4), %rax (generate address)
E+i-1 - leaq -4(%rdx, %rcx, 4), %rax (generate address)
*(E+i-3) - movl -12($rdx, %rcx, 4), %rax (reference memory)
Welcome to the Answerine , a great place to find, read and share your favorite questions and answers.
...