Assembly code of a C code
We usually use gcc to compile c codes. However, to see assembly code of the C code
that we write, we should add "-S" option while compiling the code.
gcc -S -c code.c
The command above compiles code.c as it generates code.s file which includes assembly code.
Example C code and generated Assembly Code.
code.c
#include <stdio.h>
int main(int argc, char *argv[])
{
return 0;
}
code.s
.file "code.c"
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
movl $0, %eax
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (GNU) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)"
.section .note.GNU-stack,"",@progbits
- 0 Comment
- Halil Demirezen
- 29 Jul 2008, 10:29
-
You must be login first or sign-up for an account to post comments.
USERBOX
CATEGORIES
MOST READ TODAY
- Redirecting tcp / udp ports with socat
- Java Runtime Environment on Mozilla Firefox
- Using netstat
- Fast process lookup and signaling
- Booting from an ISO image using qemu
- Converting MAC dfonts to TrueType
- Looking exim mail queue like mailq
- Find out if a command is aliased to another command
- Evaluating expressions
- Enabling remote desktop on a VirtualBox Machine
LAST ADDED
- Learning which libraries are used for a binary
- Evaluating expressions
- Using netstat
- Exim and hostname fqdn problem
- Auto directory spelling corrections
- Disabling emacs splash screen
- Getting a nice SELinux audit report
- Learning all of the available system calls
- Find out if a command is aliased to another command
- Fast process lookup and signaling
