我刚开始学习汇编程序,我一开始就被困住了——我试图调用一个简单的函数——实际上它主要是从一本书中复制而来的,而且我一直遇到分段错误。也许更有经验的人可以指出这段代码有什么问题:
.code32
SYSEXIT = 1
.data
.text
.globl _start
_start:
push $28 #just some random argument
push $33
call myfunc
mov $SYSEXIT, %eax
#exit code is stored in ebx after calling function
int $0x80
.type myfunc, @function
myfunc:
push %ebp #save old base pointer on a stack
movl %esp, %ebp
movl 8(%ebp), %ebx #first argument to ebx
movl 12(%ebp), %ecx #second argument to ecx
addl %ecx, %ebx #add arguments together - store them in ebx
movl %ebp, %esp
pop %ebp
ret