summaryrefslogtreecommitdiff
path: root/3/8_array_allocation_and_access/37_array_arithmetic.c
blob: c2ecbf268ba8dcb24ba3cdc651e04c679987bee3 (plain)
1
2
3
4
5
6
7
// S and i in rdx and rcx
//          type        value       assembly
// S+1      short *     xs + 2      leaq $2(%rdx), %rax, // leaq since we want to store the address not the value
// S[3]     short       M[xs+6]     movw $6(%rdx), %ax
// &S[i]    short *     xs+2i       leaq (rdx, rcx, 2), %rax
// S[4*i+1] short       M[xs+8i+2]  movw $2(%rdx, %rcx, 8), %ax
// S+i-5    short *     xs+2i-10    leaq $-10(%rdx, %rcx, 2), %rax