Skip to content

Instantly share code, notes, and snippets.

@dant3
Last active August 3, 2022 09:12
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 dant3/dc7f125378ad62b54b9c5d8712ad821c to your computer and use it in GitHub Desktop.
Save dant3/dc7f125378ad62b54b9c5d8712ad821c to your computer and use it in GitHub Desktop.
Hello world in assembler
segment .text ;code segment
global _start ;must be declared for linker
_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)
int 0x80 ;call kernel
segment .data ;data segment
msg db 'Hello, world!',0xa ;our dear string
len equ $ - msg ;length of our dear string
section .data
msg db "Hello world!", 0ah
len equ $ - msg
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, len
syscall
mov rax, 60
mov rdi, 0
syscall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment