2022-09-30 15:43:14 +00:00
|
|
|
section .text
|
|
|
|
global _start
|
|
|
|
_start:
|
2022-10-01 15:32:50 +00:00
|
|
|
call gettid
|
|
|
|
cmp rax, 0
|
|
|
|
jne .continue ; shenanigans: init is tid 0 (which is normally reserved for the idle task)
|
|
|
|
mov rdi, shenanigans_label
|
|
|
|
call print
|
|
|
|
jmp .end
|
|
|
|
.continue:
|
2022-10-01 13:54:42 +00:00
|
|
|
mov rdi, welcome_label
|
|
|
|
call print
|
|
|
|
call next_line
|
|
|
|
mov rdi, 1000
|
|
|
|
call sleep
|
|
|
|
mov rdi, version_label
|
|
|
|
call print
|
2022-10-01 15:32:50 +00:00
|
|
|
call get_version
|
|
|
|
mov rdi, uname
|
|
|
|
call print
|
|
|
|
call next_line
|
2022-10-01 13:54:42 +00:00
|
|
|
call next_line
|
|
|
|
mov rdi, 2000
|
|
|
|
call sleep
|
|
|
|
mov rdi, end_label
|
|
|
|
call print
|
2022-10-01 15:32:50 +00:00
|
|
|
.end:
|
2022-10-01 13:54:42 +00:00
|
|
|
call exit
|
|
|
|
|
2022-10-01 15:32:50 +00:00
|
|
|
gettid:
|
|
|
|
mov rax, 7
|
|
|
|
int 42h
|
|
|
|
ret
|
|
|
|
|
2022-10-01 13:54:42 +00:00
|
|
|
sleep:
|
2022-10-01 10:17:16 +00:00
|
|
|
mov rax, 2
|
2022-10-01 13:54:42 +00:00
|
|
|
int 42h
|
|
|
|
ret
|
|
|
|
|
|
|
|
strlen:
|
|
|
|
push rbx
|
|
|
|
push rcx
|
|
|
|
mov rbx, rdi
|
|
|
|
xor al, al
|
|
|
|
mov rcx, 0xffffffff
|
|
|
|
repne scasb
|
|
|
|
sub rdi, rbx
|
|
|
|
mov rax, rdi
|
|
|
|
pop rcx
|
|
|
|
pop rbx
|
|
|
|
dec rax
|
|
|
|
ret
|
|
|
|
|
|
|
|
print: ; string: rdi
|
|
|
|
push rdi
|
|
|
|
call strlen
|
|
|
|
mov rsi, rax
|
2022-10-01 10:17:16 +00:00
|
|
|
mov rax, 3
|
2022-10-01 13:54:42 +00:00
|
|
|
pop rdi
|
|
|
|
int 42h
|
|
|
|
ret
|
|
|
|
|
|
|
|
next_line:
|
|
|
|
mov rdi, newline
|
|
|
|
mov rsi, 1
|
|
|
|
mov rax, 3
|
|
|
|
int 42h
|
|
|
|
ret
|
|
|
|
|
|
|
|
exit:
|
2022-09-30 15:43:14 +00:00
|
|
|
mov rax, 0
|
2022-10-01 13:54:42 +00:00
|
|
|
int 42h
|
2022-10-01 10:17:16 +00:00
|
|
|
|
2022-10-01 15:32:50 +00:00
|
|
|
get_version:
|
|
|
|
mov rdi, uname
|
|
|
|
mov rsi, 40
|
|
|
|
mov rax, 6
|
|
|
|
int 42h
|
|
|
|
ret
|
|
|
|
|
2022-10-01 10:17:16 +00:00
|
|
|
section .rodata
|
2022-10-01 13:54:42 +00:00
|
|
|
version_label:
|
2022-10-01 15:32:50 +00:00
|
|
|
db "Your kernel version is ", 0
|
2022-10-01 13:54:42 +00:00
|
|
|
welcome_label:
|
|
|
|
db "Welcome to Luna!", 0xA, 0
|
|
|
|
end_label:
|
|
|
|
db "Press any key to restart.", 0xA, 0
|
2022-10-01 15:32:50 +00:00
|
|
|
shenanigans_label:
|
|
|
|
db "SHENANIGANS: init is tid 0 (reserved for the idle task)", 0xA, 0
|
2022-10-01 13:54:42 +00:00
|
|
|
newline:
|
2022-10-01 15:32:50 +00:00
|
|
|
db 0xA
|
|
|
|
|
|
|
|
section .bss
|
|
|
|
uname:
|
|
|
|
resb 40
|