做了几个实验,简单学习了解一下函数调用的开销。 程序1—没有参数的函数调用: #include <stdio.h> void test() { return; } int main(int argc, char *argv[]) { test(); return 0; } 用gcc -S得到程序1的汇编代码: .file "test.c" .text .globl test .type test, @function test: pushl %ebp movl %esp, %ebp nop popl %ebp ret .size test, .-test .globl main .type main, @function main: pushl %ebp movl %esp, %ebp call test movl $0, %eax popl %ebp ret .size main, .-main .ident "GCC: (GNU) 4.5.1 20100924 (Red Hat 4.5.1-4)" .section .note.GNU-stack,"",@progbits 从上面汇编代码可以看出,对于没有参数函数调用的开销: