Skip to content

Instantly share code, notes, and snippets.

@mts0629
Created August 31, 2018 15:26
Show Gist options
  • Save mts0629/e3ee066002b9c9f54642e7b86fcf75b0 to your computer and use it in GitHub Desktop.
Save mts0629/e3ee066002b9c9f54642e7b86fcf75b0 to your computer and use it in GitHub Desktop.
Hello world with NASM for X86_64
; ==================================================
; hello.asm
;
; $ nasm -f elf64 hello.asm -l hello.lst -o hello.o
; $ ld -s -o hello hello.o
; ==================================================
bits 64
section .text
global _start ; entry point
_start:
xor eax, eax
mov edx, eax
inc eax ; sys_write (01)
mov edi, eax ; stdout (01)
mov dl, len ; length (13)
mov rsi, msg ; address
syscall
xor edi, edi ; return 0
mov eax, edi
mov al, 60 ; sys_exit
syscall
section .data
msg db 'hello, world', 0x0A
len equ $ - msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment