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
|
|
|
|
int 42h ; syscall
|
2022-09-27 17:51:01 +00:00
|
|
|
mov rcx, 10
|
|
|
|
.loop:
|
|
|
|
dec rcx
|
2022-09-25 18:35:05 +00:00
|
|
|
mov rdi, .message
|
2022-09-29 17:17:43 +00:00
|
|
|
mov rsi, 22
|
|
|
|
mov rax, 3 ; sys_write
|
|
|
|
int 42h ; syscall
|
2022-09-27 17:51:01 +00:00
|
|
|
mov rdi, 200 ; 200 ms / 0.2 seconds
|
2022-09-29 17:17:43 +00:00
|
|
|
mov rax, 2
|
|
|
|
int 42h ; syscall
|
2022-09-27 17:51:01 +00:00
|
|
|
cmp rcx, 0
|
|
|
|
jne .loop
|
2022-09-29 17:17:43 +00:00
|
|
|
mov rax, 0
|
|
|
|
int 42h ; Exit current task
|
2022-09-25 18:35:05 +00:00
|
|
|
.message:
|
|
|
|
db "hello from userspace!", 0xA, 0
|