我正在研究Linux内核,所以我必须阅读一些汇编代码。这是一个示例代码
SYSWRITE=4
.globl mywrite,myadd
.text
mywrite:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
movl 12(%ebp),%ecx
movl 16(%ebp),%edx
movl $SYSWRITE,%eax
int $0x80
popl %ebx
movl %ebp,%esp
popl %ebp
ret
myadd:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
movl 12(%ebp),%edx
xorl %ecx,%ecx
addl %eax,%edx
jo 1f
movl 16(%ebp),%eax
movl %edx,(%eax)
incl %ecx
1:
movl %ecx,%eax
movl %ebp,%esp
popl %ebp
ret
我是这样使用as的
“as -o callee.o callee.s”
编译它,但它失败了,并显示一条类似这样的消息
“callee.s|5| 错误:‘push’的后缀或操作数无效”
最佳答案
您可能使用的是 64 位机器,因此您的 as
默认为 64 位。因为你有 32 位代码,你想使用:
as -32 -o callee.o callee.s
关于linux - 如何使用 use as in linux 和汇编语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16391536/