Last active
August 3, 2022 09:12
-
-
Save dant3/dc7f125378ad62b54b9c5d8712ad821c to your computer and use it in GitHub Desktop.
Hello world in assembler
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
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 |
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
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