Give the -S option.
The gcc-S source code.c
The -S
option in gcc allows the assembly code to be generated as shown below.
If you do not give the -o
option separately, for the same name as the source code.Generate assembly code as a file with s
suffix.
$ cat hello.c
#include <stdio.h>
int main(void)
{
printf("hello dcslab guest ;)\n");
return 0;
}
$ $ gcc -S hello.c
$ $ cat hello.s
.file "hello.c"
.section .rodata
.LC0:
.string "hello dcslab guest ;)"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $.LC0, %edi
call puts
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4"
.section .note.GNU-stack,"",@progbits
© 2024 OneMinuteCode. All rights reserved.