Skip to content

Instantly share code, notes, and snippets.

@jcrubino
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save jcrubino/e956ba64a4dcdad617ab to your computer and use it in GitHub Desktop.

Select an option

Save jcrubino/e956ba64a4dcdad617ab to your computer and use it in GitHub Desktop.
;Hello world in x86 assembly syntax (for nasm)
;to compile and run:
;$ yasm -f elf hello.asm 2>&1
;$ ld -m elf_i386 -s -o hello *.o 2>&1
section .text
global _start ;declared for linker
_start: ;linker entry point
mov edx,len ;message len
mov ecx,msg ;message to write
mov ebx,1 ;stdout
mov eax,4 ;sys_write
int 0x80 ;kernel
mov eax,1 ;sys_exit
int 0x80 ;kernel
section .data
msg db 'Hello, world!', 0xa ;the string
len equ $ - msg ;length the string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment