user1424739
user1424739

Reputation: 13755

nasm: error: instruction not supported in 16-bit mode

I am following this example. But I got this error. Does anybody know how to fix this problem? I am running on 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

How does C++ linking work in practice?

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

Upvotes: 0

Views: 7687

Answers (1)

4s7r0n4u7
4s7r0n4u7

Reputation: 96

The problem is not in the code.

The complete command to compile is nasm -f elf64 -o hello.o hello.asm

You have to specify the format (elf64) to nasm compiler using the -f option.

Upvotes: 6

Related Questions