在64位系统(GNU工具链)上组装32位二进制文件我编写可以编译的程序集代码:as power.s -o power.o当我链接power.o对象文件时出现了问题:ld power.o -o power为了在64位操作系统(Ubuntu14.04)上运行,我添加了.code32在power.s文件,但是我仍然收到错误:分段故障(堆芯倾弃)power.s:.code32
.section .data
.section .text
.global _start
_start:
pushl $3
pushl $2
call power
addl $8, %esp
pushl %eax
pushl $2
pushl $5
call power
addl $8, %esp
popl %ebx
addl %eax, %ebx
movl $1, %eax
int $0x80
.type power, @function
power:
pushl %ebp
movl %esp, %ebp
subl $4, %esp
movl 8(%ebp), %ebx
movl 12(%ebp), %ecx
movl %ebx, -4(%ebp)
power_loop_start:
cmpl $1, %ecx
je end_power
movl -4(%ebp), %eax
imull %ebx, %eax
movl %eax, -4(%ebp)
decl %ecx
jmp power_loop_start
end_power:
movl -4(%ebp), %eax
movl %ebp, %esp
popl %ebp
ret
2 回答
- 2 回答
- 0 关注
- 836 浏览
添加回答
举报
0/150
提交
取消