Skip to content

Instantly share code, notes, and snippets.

@thewh1teagle
Last active May 16, 2022 08:22
Show Gist options
  • Save thewh1teagle/0c906a8a3a8bc8f99743c174b4a579f5 to your computer and use it in GitHub Desktop.
Save thewh1teagle/0c906a8a3a8bc8f99743c174b4a579f5 to your computer and use it in GitHub Desktop.
hello world assembly x86
# Useful variables
STDIN equ 0
STDOUT equ 1
STDERR equ 2
SYS_READ equ 0
SYS_WRITE equ 4
SYS_EXIT equ 1
KERNEL equ 0x80
%macro syscall 0
int KERNEL ;call kernel
%endmacro
%macro exit_success 0
mov eax, SYS_EXIT
syscall
%endmacro
section .data ; here we store variables
msg db "Hello world!", 0xa ; 0xa is new line
len equ $ - msg
section .text
global _start
_start: ; main function
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,STDOUT ;file descriptor (stdout)
mov eax,SYS_WRITE ;system call number (sys_write)
syscall
exit_success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment