Skip to content

Instantly share code, notes, and snippets.

@HorlogeSkynet
Last active November 4, 2017 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HorlogeSkynet/eff0a7e307809c1b661a87d88bd33f21 to your computer and use it in GitHub Desktop.
Save HorlogeSkynet/eff0a7e307809c1b661a87d88bd33f21 to your computer and use it in GitHub Desktop.
A simple "Hello, world !" (debuggable) program for NASM with Linux
; Copyright (c) 1999 Konstantin Boldyshev <konst@linuxassembly.org>
;
; Reviewed by HorlogeSkynet (12/09/16)
;
; "Hello, world !" in assembly language for Linux
; To compile: nasm -f elf64 -g helloWorld.asm
; To link the executable: ld -m elf_x86_64 -g -o helloWorld helloWorld.o
; To run the program: ./helloWorld
; To debug the program: gdb ./helloWorld
section .data
msg db 'Hello, world !', 0xa ; Our dear string
len equ $ - msg ; Length of our dear string
section .text
global _start ; Must be declared for linker (ld)
_start: ; Tell linker entry point
mov edx, len ; Message length
mov ecx, msg ; Message to write
mov ebx, 1 ; File descriptor (stdout)
mov eax, 4 ; System call number (sys_write)
int 0x80 ; Call kernel
mov eax, 1 ; System call number (sys_exit)
mov ebx, 0 ; Set the returned value
int 0x80 ; Call kernel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment