I am trying to store a stack memory address into a register. The point is to call a c function from assembly code that takes in three arguments.
1) A pointer to a function: which I get using leaq label(%rip), %rdi
2) An int: which is simple, movq $2, %rsi
3) A pointer to a memory address: This is the tricky part. This address is lets say stack location 2 = -16(%rsp).
How to pass this stack location to the register %rdx and have the c function write its results there?
Note: This c function is pthread threaded if you need to know.
foo() { int k; bar(&k); }godbolt.org/g/kfPqic.