Last active
May 16, 2022 08:22
-
-
Save thewh1teagle/0c906a8a3a8bc8f99743c174b4a579f5 to your computer and use it in GitHub Desktop.
hello world assembly x86
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
# 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