Last active
November 4, 2017 05:05
-
-
Save HorlogeSkynet/eff0a7e307809c1b661a87d88bd33f21 to your computer and use it in GitHub Desktop.
A simple "Hello, world !" (debuggable) program for NASM with Linux
This file contains 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
; 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