Simplest working example I could think of:
test.c
test.SCode:#include <stdio.h> void asmfunction(void); int test_variable = 0; int main() { printf("before asm: %d\n", test_variable); asmfunction(); printf("after asm: %d\n", test_variable); return 0; }
$ gcc test.c test.SCode:.globl _asmfunction _asmfunction: movl $12345, (_test_variable) ret
$ ./a.exe
before asm: 0
after asm: 12345
Notice how all the names are prefix with an underscore in the assembler file but not in the C file. Although I'm not sure if this is standard for gcc/gas or if it is cygwin specific.
Edit:
I just noticed that the underscore and lack of '$' had already been mentioned before. I blame needing to look up this stupid AT&T syntax which took to much time
RIP is the x64 version of the instruction pointer.
It can be used for addressing variables in a way where the address of the variable is stored as an offset relative to the current IP to create position independent code. This is called RIP-relative addressing.
For some more detailed information see for example Intel® 64 and IA-32 Architectures Software Developer's Manuals volume 2a section 2.2.1.6