|
发表于 2014-2-6 17:44:30
|
显示全部楼层
研究一下你的代码吧
.file "std.c"
.comm n,4,4
.section .rodata
.LC0:
.string "\350\257\267\351\200\211\346\213\251\346\217\222\345\205\245\347\202\271"
.LC1:
.string "%d"
.LC2:
.string "\345\234\250%d\345\255\246\347\224\237\344\271\213\345\220\216\346\217\222\345\205\245\n"
.text
.globl main
.type main, @function
main:
.LFB2:
.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, 24(%esp)
call creat
movl %eax, 28(%esp)
movl 28(%esp), %eax
movl %eax, (%esp)
call print
movl $.LC0, (%esp)
call puts
leal 24(%esp), %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
movl 24(%esp), %eax
movl %eax, 4(%esp)
movl $.LC2, (%esp)
call printf
movl 24(%esp), %eax
movl %eax, 4(%esp)
movl 28(%esp), %eax
movl %eax, (%esp)
call insert_link
movl %eax, (%esp)
call print
movl $0, %eax
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE2:
.size main, .-main
.section .rodata
.LC3:
.string "\350\257\267\350\276\223\345\205\245\345\255\246\345\217\267\357\274\232"
.align 4
.LC4:
.string "\350\276\223\345\205\245\346\234\211\350\257\257\357\274\214\350\257\267\351\207\215\346\226\260\350\276\223\345\205\245\345\255\246\345\217\267\357\274\201"
.LC5:
.string "\350\257\267\350\276\223\345\205\245\345\210\206\346\225\260\357\274\232"
.align 4
.LC6:
.string "\350\276\223\345\205\245\346\234\211\350\257\257\357\274\214\350\257\267\351\207\215\346\226\260\350\276\223\345\205\245\345\210\206\346\225\260\357\274\201"
.text
.globl creat
.type creat, @function
creat:
.LFB3:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
subl $40, %esp
movl $0, -12(%ebp)
movl $12, (%esp)
call malloc
movl %eax, -20(%ebp)
movl -20(%ebp), %eax
movl %eax, -16(%ebp)
movl $.LC3, (%esp)
call puts
jmp .L4
.L5:
movl $.LC4, (%esp)
call puts
call getchar
.L4:
movl -16(%ebp), %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L5
movl $.LC5, (%esp)
call puts
jmp .L6
.L7:
movl $.LC6, (%esp)
call puts
call getchar
.L6:
movl -16(%ebp), %eax
addl $4, %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L7
jmp .L8
.L15:
movl n, %eax
addl $1, %eax
movl %eax, n
movl n, %eax
cmpl $1, %eax
jne .L9
movl -16(%ebp), %eax
movl %eax, -12(%ebp)
jmp .L10
.L9:
movl -20(%ebp), %eax
movl -16(%ebp), %edx
movl %edx, 8(%eax)
.L10:
movl -16(%ebp), %eax
movl %eax, -20(%ebp)
movl $12, (%esp)
call malloc
movl %eax, -16(%ebp)
movl $.LC3, (%esp)
call puts
jmp .L11
.L12:
movl $.LC4, (%esp)
call puts
call getchar
.L11:
movl -16(%ebp), %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L12
movl $.LC5, (%esp)
call puts
jmp .L13
.L14:
movl $.LC6, (%esp)
call puts
call getchar
.L13:
movl -16(%ebp), %eax
addl $4, %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L14
.L8:
movl -16(%ebp), %eax
movl (%eax), %eax
testl %eax, %eax
jne .L15
movl -20(%ebp), %eax
movl $0, 8(%eax)
movl -12(%ebp), %eax
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE3:
.size creat, .-creat
.section .rodata
.LC7:
.string "\345\205\261\346\234\211%d\346\235\241\350\256\260\345\275\225\n"
.align 4
.LC8:
.string "\345\255\246\345\217\267\344\270\272\357\274\232%d\t\345\210\206\346\225\260\344\270\272\357\274\232%d\n"
.text
.globl print
.type print, @function
print:
.LFB4:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
subl $24, %esp
movl n, %eax
movl %eax, 4(%esp)
movl $.LC7, (%esp)
call printf
jmp .L18
.L19:
movl 8(%ebp), %eax
movl 4(%eax), %edx
movl 8(%ebp), %eax
movl (%eax), %eax
movl %edx, 8(%esp)
movl %eax, 4(%esp)
movl $.LC8, (%esp)
call printf
movl 8(%ebp), %eax
movl 8(%eax), %eax
movl %eax, 8(%ebp)
.L18:
cmpl $0, 8(%ebp)
jne .L19
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE4:
.size print, .-print
.section .rodata
.align 4
.LC9:
.string "\350\257\245\350\241\250\344\270\272\347\251\272\350\241\250\357\274\214\346\267\273\345\212\240\350\256\260\345\275\225\357\274\201"
.text
.globl insert_link
.type insert_link, @function
insert_link:
.LFB5:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
subl $72, %esp
cmpl $0, 8(%ebp)
jne .L21
leal -28(%ebp), %eax
movl %eax, 8(%ebp)
movl $.LC9, (%esp)
call puts
movl $.LC3, (%esp)
call puts
jmp .L22
.L23:
movl $.LC4, (%esp)
call puts
call getchar
.L22:
leal -28(%ebp), %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L23
movl $.LC5, (%esp)
call puts
jmp .L24
.L25:
movl $.LC6, (%esp)
call puts
call getchar
.L24:
leal -28(%ebp), %eax
addl $4, %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L25
movl $0, -20(%ebp)
movl $0, -12(%ebp)
movl $0, -16(%ebp)
movl 8(%ebp), %eax
jmp .L26
.L21:
movl 8(%ebp), %eax
movl %eax, -12(%ebp)
jmp .L27
.L29:
movl -12(%ebp), %eax
movl %eax, -16(%ebp)
movl -12(%ebp), %eax
movl 8(%eax), %eax
movl %eax, -12(%ebp)
.L27:
movl -12(%ebp), %eax
movl (%eax), %eax
cmpl 12(%ebp), %eax
je .L28
movl -12(%ebp), %eax
movl 8(%eax), %eax
testl %eax, %eax
jne .L29
.L28:
movl -16(%ebp), %eax
movl (%eax), %eax
cmpl 12(%ebp), %eax
jne .L30
movl $.LC3, (%esp)
call puts
jmp .L31
.L32:
movl $.LC4, (%esp)
call puts
call getchar
.L31:
leal -40(%ebp), %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L32
movl $.LC5, (%esp)
call puts
jmp .L33
.L34:
movl $.LC6, (%esp)
call puts
call getchar
.L33:
leal -40(%ebp), %eax
addl $4, %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L34
movl -16(%ebp), %eax
leal -40(%ebp), %edx
movl %edx, 8(%eax)
movl -12(%ebp), %eax
movl %eax, -32(%ebp)
jmp .L35
.L30:
movl $.LC3, (%esp)
call puts
jmp .L36
.L37:
movl $.LC4, (%esp)
call puts
call getchar
.L36:
leal -52(%ebp), %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L37
movl $.LC5, (%esp)
call puts
jmp .L38
.L39:
movl $.LC6, (%esp)
call puts
call getchar
.L38:
leal -52(%ebp), %eax
addl $4, %eax
movl %eax, 4(%esp)
movl $.LC1, (%esp)
call __isoc99_scanf
cmpl $1, %eax
jne .L39
movl -12(%ebp), %eax
leal -52(%ebp), %edx
movl %edx, 8(%eax)
movl $0, -44(%ebp)
.L35:
movl 8(%ebp), %eax
.L26:
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE5:
.size insert_link, .-insert_link
.ident "GCC: (GNU) 4.8.2 20131212 (Red Hat 4.8.2-7)"
.section .note.GNU-stack,"",@progbits |
|