Created
August 31, 2018 15:26
-
-
Save mts0629/e3ee066002b9c9f54642e7b86fcf75b0 to your computer and use it in GitHub Desktop.
Hello world with NASM for X86_64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ================================================== | |
; 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