2022-09-18 15:03:29 +00:00
|
|
|
global _main
|
|
|
|
extern _start
|
|
|
|
|
|
|
|
_main:
|
|
|
|
xor rbp, rbp
|
2022-09-25 18:35:05 +00:00
|
|
|
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
|
2022-09-25 18:35:05 +00:00
|
|
|
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
|
2022-09-25 18:35:05 +00:00
|
|
|
.message:
|
2022-09-29 18:06:18 +00:00
|
|
|
db "userspace preparing for painting", 0xA
|