vc6/kernel/kernel.vc6asm
2026-11-14 05:21:53 +01:00

128 lines
1.7 KiB
Plaintext

@include "../common/arch.vc6asm"
@include "../common/macros.vc6asm"
@const k_stack_base 0x1fff
@const k_heap_base 0x2000
@org 0x0800
main:
mov bp, k_stack_base
mov sp, bp
mov r0, 40 * 5
store [Vcd.row], r0
mov r1, .splash_str
call println
mov r1, .prompt
call puts
mov r0, keydown_handler
store [KBD_KEYDOWN_HANDLER], r0
mov r1, 0
sti
.spin:
hlt
jr .spin
.splash_str:
dw "THIS IS FROM THE KERNEL YAYYYY!!!!\0"
.prompt:
dw "> \0"
keydown_handler:
load r1, [KBD_SCANCODE]
add r1, 93
call putc
sti
ret
@const vcd_width 40
@const vcd_height 25
Vcd:
.col: dw 0
.row: dw 0
; r1 character
putc:
cmp r1, '\n'
je .newline
load r2, [Vcd.col]
load r3, [Vcd.row]
add r3, r2
add r3, VCD_BEGIN
store [r3], r1
add r2, 1
cmp r2, vcd_width
jge .newline
store [Vcd.col], r2
ret
.newline:
mov r2, 0
store [Vcd.col], r2
load r3, [Vcd.row]
add r3, 40
cmp r3, vcd_width * vcd_height
jge .scroll
store [Vcd.row], r3
ret
.scroll:
mov r1, VCD_BEGIN
mov r2, VCD_BEGIN + vcd_width
mov r3, vcd_width * (vcd_height - 1)
call memmove
mov r1, VCD_BEGIN + vcd_width * (vcd_height - 1)
mov r2, 0
mov r3, vcd_width
call memset
mov r3, vcd_width * (vcd_height - 1)
store [Vcd.row], r3
ret
; r1 string
puts:
push r1
jmp .l0_cond
.l0_body:
store [sp], r1
load r1, [r1]
call putc
load r1, [sp]
add r1, 1
.l0_cond:
load r2, [r1]
cmp r2, '\0'
jne .l0_body
pop r1
ret
; r1 string
println:
call puts
mov r1, '\n'
jmp putc
; r1 format string
; r2 args
; ---
; r0 words printed
printf:
@include "../common/memstr.vc6asm"