Zdravim, zacinam s asm spravil som maly programik a disasemblil som ho a neviem pochopit uvod main (prekladac gcc)
programik skompilovany s flagmy -c -O2 (s O2 je to omnoh citatelnejsie :) )
int b(int x ) {
return x + 1;
}
int main() {
int a = 1;
a +=b(1);
return a;
}
a disasm:
Disassembly of section .text:
00000000 <b>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 8b 45 08 mov 0x8(%ebp),%eax
6: 5d pop %ebp
7: 83 c0 01 add $0x1,%eax
a: c3 ret
b: 90 nop
c: 8d 74 26 00 lea 0x0(%esi),%esi
00000010 <main>:
10: 8d 4c 24 04 lea 0x4(%esp),%ecx
14: 83 e4 f0 and $0xfffffff0,%esp
17: ff 71 fc pushl 0xfffffffc(%ecx)
1a: 55 push %ebp
1b: 89 e5 mov %esp,%ebp
1d: 51 push %ecx
1e: 83 ec 04 sub $0x4,%esp
21: c7 04 24 01 00 00 00 movl $0x1,(%esp)
28: e8 fc ff ff ff call 29 <main+0x19>
2d: 83 c4 04 add $0x4,%esp
30: 59 pop %ecx
31: 5d pop %ebp
32: 8d 61 fc lea 0xfffffffc(%ecx),%esp
35: 83 c0 01 add $0x1,%eax
38: c3 ret
No, a ja nedokazem pochopit na cu su dobre tie 1. tri riadky:
10: 8d 4c 24 04 lea 0x4(%esp),%ecx
14: 83 e4 f0 and $0xfffffff0,%esp
17: ff 71 fc pushl 0xfffffffc(%ecx)
p.s. je to tam aj bez optimalizacie (bez -O alebo -O0)
Diky moc.