NASM入門 Hello,World

global _start

section .text
_start:
  mov rax, 1  ;システムコールをwriteに設定
  mov rdi, 1  ;出力先をstdoutに設定
  mov rsi, message  ;出力する文字列の先頭アドレスを設定
  mov rdx, 13  ;出力する文字列のバイト数を設定
  syscall  ;システムコールを実行
  mov rax, 60  ;システムコールをexitに設定
  xor rdi, rdi  ;exitのコードを0に設定
  syscall  ;システムコールを実行

section .data
message: db "Hello, World", 10  ;出力する文字列 最後の10は改行(LF)
nasm -felf64 hello.asm
ld -o hello hello.o
./hello