C函数调用的汇编语言函数基本模板
/*
被调用的函数必须保留EBX、EDI、ESI、EBP和ESP寄存器
*/
.section .text
.type func, @function
func:
pushl %ebp
movl %esp, %ebp
subl $12, %esp
pushl %edi
pushl %esi
pushl %ebx
<function code>
popl %ebx
popl %esi
popl %edi
movl %ebp, %esp
popl %ebp
ret
/*
被调用的函数必须保留EBX、EDI、ESI、EBP和ESP寄存器
*/
.section .text
.type func, @function
func:
pushl %ebp
movl %esp, %ebp
subl $12, %esp
pushl %edi
pushl %esi
pushl %ebx
<function code>
popl %ebx
popl %esi
popl %edi
movl %ebp, %esp
popl %ebp
ret