Mach-O 64位格式不支持32位绝对地址.美国宇航局 [英] Mach-O 64-bit format does not support 32-bit absolute addresses. NASM
问题描述
当我使用nasm -f macho64 asm1.asm
时,出现以下错误:
When I use nasm -f macho64 asm1.asm
I get the following error:
asm1.asm:14:错误:Mach-O 64位格式不支持32位绝对地址
asm1.asm:14: error: Mach-O 64-bit format does not support 32-bit absolute addresses
这是asm1.asm
SECTION .data ;initialized data
msg: db "Hello world, this is assembly", 10, 0
SECTION .text ;asm code
extern printf
global _main
_main:
push rbp
mov rbp, rsp
push msg
call printf
mov rsp, rbp
pop rbp
ret
我真的是汇编的新手,几乎不知道这些命令的作用.知道这里有什么问题吗?
I'm really new to assembly and barely know what these commands do. Any idea what's wrong here?
推荐答案
与其他UNIX/POSIX系统一样,Mac OS X对64位代码使用不同的调用约定.而不是将所有参数都推入堆栈,它对前6个参数使用RDI
,RSI
,RDX
,RCX
,R8
和R9
.因此,除了使用push msg
之外,您还需要使用类似mov RDI, msg
的东西.
Mac OS X, like other UNIX/POSIX systems, uses a different calling convention for 64-bit code. Instead of pushing all the arguments to the stack, it uses RDI
, RSI
, RDX
, RCX
, R8
, and R9
for the first 6 arguments. So instead of using push msg
, you'll need to use something like mov RDI, msg
.
这篇关于Mach-O 64位格式不支持32位绝对地址.美国宇航局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!