assembly nasm:错误:16位模式下不支持指令

e3bfsja2  于 2023-11-19  发布在  其他
关注(0)|答案(1)|浏览(228)

我按照这个例子。但我得到了这个错误。有人知道如何解决这个问题吗?我在Mac OS X 10.14.1上运行。

$ nasm -o hello_world.o hello_world.asm
hello_world.asm:8: error: instruction not supported in 16-bit mode
hello_world.asm:9: error: instruction not supported in 16-bit mode
hello_world.asm:10: error: instruction not supported in 16-bit mode
hello_world.asm:11: error: instruction not supported in 16-bit mode
hello_world.asm:15: error: instruction not supported in 16-bit mode
hello_world.asm:16: error: instruction not supported in 16-bit mode
$ nasm --version
NASM version 2.13.03 compiled on Feb  8 2018

字符串
C++链接在实践中是如何工作的?

section .data
hello_world db "Hello world!", 10
section .text
global _start
_start:

; sys_write
mov rax, 1
mov rdi, 1
mov rsi, hello_world
mov rdx, 13
syscall

; sys_exit
mov rax, 60
mov rdi, 0
syscall

ev7lccsx

ev7lccsx1#

问题不在代码中。
完整的编译命令是nasm -f elf64 -o hello.o hello.asm
您必须使用-f选项为nasm编译器指定格式(elf64)。

相关问题