Last active
August 29, 2015 14:16
-
-
Save paked/f755cd3707905cccd201 to your computer and use it in GitHub Desktop.
A hello-world-esque program in assembly!
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
; This program prints "Hack the planet!" to stdout | |
; @author Harrison <github.com/paked> | |
; I'd like to thank the academy for helping me get this far. | |
; build: `nasm -f elf64 -F stabs hello_world.asm` | |
; link: `ld -o hello_world hello_world.o` | |
; run: `./hello_world` | |
section .data ; group "data" related stuff into this section | |
hello: db 'Hack the Planet!',10 ; string to print to stout | |
helloLen: equ $-hello ; length of the string, used to set correct buffer size | |
section .text ; section for the text printing! | |
global _start ; allow _start to be publicly accesible as the entry point of the program | |
_start: ; definition of the start procedure | |
mov eax,4 ; sys_write function code | |
mov ebx,1 ; set output to stdout | |
mov ecx,hello ; pass hello string into buffer | |
mov edx,helloLen ; specifiy the buffers length | |
int 80h ; interupt the kernel with "hey execute that sys_call I just set up!" | |
mov eax,1 ; sys_exit function code | |
mov ebx,0 ; set return code (0=OK,>0=SOMETHING WENT WRONG!) | |
int 80h ; interupt the kernel with the sys_exit call that was just set up! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment