- 论坛徽章:
- 0
|
回复 #10 bugboy_bugboy 的帖子
对应的汇编:
///////////////////可以运行的//////////////////////////////
.file "t.c"
.text
.globl B
.type B, @function
B:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl 8(%ebp), %edx
movb $97, -12(%ebp)
movb $0, -11(%ebp)
movl -16(%ebp), %eax
movl %eax, (%edx)
movl -12(%ebp), %eax
movl %eax, 4(%edx)
movl -8(%ebp), %eax
movl %eax, 8(%edx)
movl -4(%ebp), %eax
movl %eax, 12(%edx)
movl %edx, %eax
leave
ret $4
.size B, .-B
.section .rodata
.LC0:
.string "%s\n"
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $36, %esp
leal -20(%ebp), %eax
movl %eax, (%esp)
call B
subl $4, %esp
movl -16(%ebp), %eax
movl %eax, 4(%esp)
movl -12(%ebp), %eax
movl %eax, 8(%esp)
movzwl -8(%ebp), %eax
movw %ax, 12(%esp)
movl $.LC0, (%esp)
call printf
movl -4(%ebp), %ecx
leave
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (GNU) 4.1.0 20060304 (Red Hat 4.1.0-3)"
.section .note.GNU-stack,"",@progbits
////////////////////挂掉的汇编////////////////////////////
.file "t1.c"
.text
.globl B
.type B, @function
B:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl 8(%ebp), %edx
movb $97, -12(%ebp)
movb $0, -11(%ebp)
movl -16(%ebp), %eax
movl %eax, (%edx)
movl -12(%ebp), %eax
movl %eax, 4(%edx)
movl -8(%ebp), %eax
movl %eax, 8(%edx)
movl -4(%ebp), %eax
movl %eax, 12(%edx)
movl %edx, %eax
leave
ret $4
.size B, .-B
.section .rodata
.LC0:
.string "%s\n"
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $52, %esp
leal -20(%ebp), %eax
movl %eax, (%esp)
call B
subl $4, %esp
movl -16(%ebp), %eax
movl %eax, 4(%esp)
movl -12(%ebp), %eax
movl %eax, 8(%esp)
movzwl -8(%ebp), %eax
movw %ax, 12(%esp)
movl $.LC0, (%esp)
call printf
movl -4(%ebp), %ecx
leave
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (GNU) 4.1.0 20060304 (Red Hat 4.1.0-3)"
.section .note.GNU-stack,"",@progbits |
|