Skip to content

Instantly share code, notes, and snippets.

@Nitrodist
Created November 24, 2011 00:56
Show Gist options
  • Save Nitrodist/1390383 to your computer and use it in GitHub Desktop.
Save Nitrodist/1390383 to your computer and use it in GitHub Desktop.
http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax
mark@linux-qmbm ~$ cat hello.c
#include <stdio.h>
int main(void) {
printf("Hello, world!\n");
return 0;
}
mark@linux-qmbm ~$ gcc -o hello hello.c
mark@linux-qmbm ~$ ./hello
Hello, world!
mark@linux-qmbm ~$ gcc -S -m32 hello.c
mark@linux-qmbm ~$ wc -l hello.s
22 hello.s
mark@linux-qmbm ~$ cat hello.s
.file "hello.c"
.section .rodata
.LC0:
.string "Hello, world!"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $16, %esp
movl $.LC0, (%esp)
call puts
movl $0, %eax
leave
ret
.size main, .-main
.ident "GCC: (SUSE Linux) 4.5.0 20100604 [gcc-4_5-branch revision 160292]"
.section .comment.SUSE.OPTs,"MS",@progbits,1
.string "ospwg"
.section .note.GNU-stack,"",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment