:~/wenjian/bowl$ gcc -S tie.c -o tie.s
:~/wenjian/bowl$ vim tie.s
:~/wenjian/bowl$ cat tie.c tie.s
#include
int main(void)
{
int n;
int sum=0;
do{
printf("please enter an integer:\n");
scanf("%d",&n);
sum=sum+n;
printf("the sum is %d\n\n",sum);
}while(n!=0);
return 0;
}
.file "tie.c"
.section .rodata
.LC0:
.string "please enter an integer:"
.LC1:
.string "%d"
.LC2:
.string "the sum is %d\n\n"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
andl $-16, %esp
subl $32, %esp
movl $0, 28(%esp)
.L2:
movl $.LC0, (%esp)
call puts
leal 24(%esp), %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
movl 24(%esp), %eax
addl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $.LC2, (%esp)
call printf
movl 24(%esp), %eax
testl %eax, %eax
jne .L2
movl $0, %eax
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"
.section .note.GNU-stack,"",@progbits