- 论坛徽章:
- 11
|
jallyx 发表于 2012-03-31 13:14 ![]()
个人感觉一个实现是由编译器负责初始化,一个是通过函数调用搞定的,编译器初始化效率>函数调用。
(gdb) si
0x00001ec1 14 char buf[1024] = {0};
(gdb) disassemble
Dump of assembler code for function test2:
0x00001ea0 <test2+0>: push %ebp
0x00001ea1 <test2+1>: mov %esp,%ebp
0x00001ea3 <test2+3>: push %esi
0x00001ea4 <test2+4>: sub $0x414,%esp
0x00001eaa <test2+10>: call 0x1eaf <test2+15>
0x00001eaf <test2+15>: pop %eax
0x00001eb0 <test2+16>: mov 0x16d(%eax),%ecx
0x00001eb6 <test2+22>: mov (%ecx),%ecx
0x00001eb8 <test2+24>: mov %ecx,-0x8(%ebp)
0x00001ebb <test2+27>: lea -0x408(%ebp),%ecx
0x00001ec1 <test2+33>: mov %ecx,%edx
0x00001ec3 <test2+35>: mov %esp,%esi
0x00001ec5 <test2+37>: mov %edx,(%esi)
0x00001ec7 <test2+39>: movl $0x400,0x4(%esi)
0x00001ece <test2+46>: mov %eax,-0x40c(%ebp)
0x00001ed4 <test2+52>: mov %ecx,-0x410(%ebp)
0x00001eda <test2+58>: call 0x1f52 <dyld_stub___bzero>
|
|