summaryrefslogtreecommitdiff
path: root/3/8_array_allocation_and_access/37_array_arithmetic.c
diff options
context:
space:
mode:
Diffstat (limited to '3/8_array_allocation_and_access/37_array_arithmetic.c')
-rw-r--r--3/8_array_allocation_and_access/37_array_arithmetic.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/3/8_array_allocation_and_access/37_array_arithmetic.c b/3/8_array_allocation_and_access/37_array_arithmetic.c
new file mode 100644
index 0000000..c2ecbf2
--- /dev/null
+++ b/3/8_array_allocation_and_access/37_array_arithmetic.c
@@ -0,0 +1,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