hello world

This commit is contained in:
root 2025-05-04 11:19:41 +00:00
parent f15e3f33c2
commit 1f0adc0a69
2 changed files with 35 additions and 0 deletions

27
hello.s Normal file
View file

@ -0,0 +1,27 @@
global _start
; constants
SYS_WRITE equ 1
SYS_EXIT equ 60
STDOUT equ 1
SECTION .data
hello db "Hello world!", 0x0a
hello_len equ $ - hello
SECTION .text
_start:
; syscall(SYS_WRITE, STDOUT, hello, hello_len);
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, hello
mov rdx, hello_len
syscall
push rax
; syscall(SYS_EXIT, <sys_write return value> - hello_len);
mov rax, SYS_EXIT
pop rdi
sub rdi, hello_len
syscall