- 论坛徽章:
- 0
|
printf为什么会这样?
无可置疑,先调用的func(2),然后调用的func(1),见汇编代码,一切都清楚了:
- Disassembly of section .text:
- 00000000 <.text>;:
- 0: 6e outsb %ds:(%esi),(%dx)
- 1: 75 6d jne 70 <_main+0x36>;
- 3: 62 65 72 bound %esp,0x72(%ebp)
- 6: 20 25 64 00 55 89 and %ah,0x89550064
- 0000000a <_Func>;:
- a: 55 push %ebp
- b: 89 e5 mov %esp,%ebp
- d: 83 ec 18 sub $0x18,%esp
- 10: 8b 45 08 mov 0x8(%ebp),%eax
- 13: 89 44 24 08 mov %eax,0x8(%esp)
- 17: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
- 1e: 00
- 1f: c7 04 24 00 00 00 00 movl $0x0,(%esp)
- 26: e8 00 00 00 00 call 2b <_Func+0x21>;
- 2b: b8 00 00 00 00 mov $0x0,%eax
- 30: c9 leave
- 31: c3 ret
- 32: 25 73 2c 20 25 and $0x25202c73,%eax
- 37: 73 0a jae 43 <_main+0x9>;
- ...
- 0000003a <_main>;:
- 3a: 55 push %ebp
- 3b: 89 e5 mov %esp,%ebp
- 3d: 53 push %ebx
- 3e: 83 ec 14 sub $0x14,%esp
- 41: 83 e4 f0 and $0xfffffff0,%esp
- 44: b8 00 00 00 00 mov $0x0,%eax
- 49: 89 45 f8 mov %eax,0xfffffff8(%ebp)
- 4c: 8b 45 f8 mov 0xfffffff8(%ebp),%eax
- 4f: e8 00 00 00 00 call 54 <_main+0x1a>;
- 54: e8 00 00 00 00 call 59 <_main+0x1f>;
- 59: c7 04 24 02 00 00 00 movl $0x2,(%esp);2入栈
- 60: e8 a5 ff ff ff call a <_Func>;
- 65: 89 c3 mov %eax,%ebx
- 67: c7 04 24 01 00 00 00 movl $0x1,(%esp);1入栈
- 6e: e8 97 ff ff ff call a <_Func>;
- 73: 89 5c 24 08 mov %ebx,0x8(%esp)
- 77: 89 44 24 04 mov %eax,0x4(%esp)
- 7b: c7 04 24 32 00 00 00 movl $0x32,(%esp)
- 82: e8 00 00 00 00 call 87 <_main+0x4d>;
- 87: 8b 5d fc mov 0xfffffffc(%ebp),%ebx
- 8a: c9 leave
- 8b: c3 ret
- 8c: 90 nop
- 8d: 90 nop
- 8e: 90 nop
- 8f: 90 nop
复制代码 |
|