If I have to translate a simple C function with some kind of addressing like this:
void f(int *a, int *b, long i){
a[i] = b[i];
}
in System V AMD X86-64 (AT&T standard) assembly, using indirect addressing with index
, base
register plus a scale
value.
So, because there's not any kind of arithmetic on pointer in assembly, the scale value should be 4
for a integer pointer?
Is this code correct?
f:
pushq %rpb # editor's note: typo for %rbp
movq %rsp, %rbp
movl (%rsi, %rdx, 4), %eax
movl %eax, (%rdi, %rdx, 4)
popq %rbp
ret