feat(app): nolibc hello world

This commit is contained in:
2026-04-20 16:00:17 +02:00
parent d829209488
commit d5be4cfe0b
5 changed files with 103 additions and 1 deletions

29
app/entry.s Normal file
View File

@@ -0,0 +1,29 @@
.global _start, syscall5
_start:
/* Load argc -> rdi, argv[0] -> rsi */
xor %rbp, %rbp
pop %rdi
mov %rsp, %rsi
and $0xFFFFFFFFFFFFFFF0, %rsp
call main
/* Exit with ret val of main */
mov %rax, %rdi
mov $0x3C, %rax
syscall
syscall5:
mov %rdi, %rax /* %rax (syscall number) = func param 1 (%rdi) */
mov %rsi, %rdi /* %rdi (syscall param 1) = func param 2 (%rsi) */
mov %rdx, %rsi /* %rsi (syscall param 2) = func param 3 (%rdx) */
mov %rcx, %rdx /* %rdx (syscall param 3) = func param 4 (%rcx) */
mov %r8, %r10 /* %r10 (syscall param 4) = func param 5 (%r8) */
mov %r9, %r8 /* %r8 (syscall param 5) = func param 6 (%r9) */
syscall /* Enter a syscall (return value in %rax) */
ret /* Return value is already in %rax, we can return. */
.section .note.GNU-stack,"",@progbits