Luna/kernel/src/main.asm

44 lines
845 B
NASM
Raw Normal View History

global _main
extern _start
_main:
xor rbp, rbp
call _start
global _userspace
_userspace:
mov rdi, 4000 ; 4000 ms / 4 seconds
2022-09-29 17:17:43 +00:00
mov rax, 2 ; sys_sleep
2022-09-29 18:06:18 +00:00
int 42h
cmp rax, 0
jne .fail ; syscall failed
mov rdi, .message
2022-09-29 18:06:18 +00:00
mov rsi, 33
2022-09-29 17:17:43 +00:00
mov rax, 3 ; sys_write
2022-09-29 18:06:18 +00:00
int 42h
cmp rax, 33
jne .fail ; syscall did not write enough bytes
.draw:
mov rax, 5 ; sys_rand
int 42h
mov r9, rax ; color
mov rdi, 20 ; x
mov rsi, 20 ; y
mov r10, 40 ; width
mov r8, 30 ; height
mov rax, 4 ; sys_paint
int 42h
cmp rax, 0
jne .fail
mov rdi, 100
mov rax, 2 ; sys_sleep
int 42h
cmp rax, 0
jne .fail
jmp .draw
.fail:
mov rax, 0 ; sys_exit
int 42h
jmp $ ; sys_exit failed, nothing more we can do
.message:
2022-09-29 18:06:18 +00:00
db "userspace preparing for painting", 0xA