assembly - nasm:错误:16 位模式不支持指令
问题描述
我正在关注这个例子。但我得到了这个错误。有谁知道如何解决这个问题?我在 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
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
解决方案
问题不在代码中。
完整的编译命令是nasm -f elf64 -o hello.o hello.asm
您必须使用该选项指定nasm
编译器的格式(elf64)。-f
推荐阅读
- regex - python 2.6 和 2.7 中 re._compile 的区别
- c# - 我可以在 asp.net core 2.1 MVC 的前端直接更改,而不重新发布解决方案吗
- c# - Automapper 和命名约定
- angular - Angular6 Material Datepicker向模板添加内容
- git - Git:在推送后恢复与意外丢弃的文件的合并
- sql - BULK COLLECT INTO 具有多行的动态列数
- r - 在 R 中的 Days 中创建任期列
- bash - Bash 在标记之前删除文件中的行并将输出保存到文件中
- apache - Apache 中使用 Kerberos 的 SSO - 日志中没有用户名?
- javascript - 用正则表达式模式替换标志“i”