rdos/kernel/main.asm

119 lines
1.5 KiB
NASM
Raw Normal View History

cpu 8086
org 0x0000
db 0x55, 0xAA, 0x00
jmp optrom_init
times (0x1A - ($-$$)) db 0
dw pnp
align 16
pnp:
db "$PnP"
db 1 ; version 1
db 2 ; 2 * 16 length
dw 0 ; offset of next header
db 0
db 0 ; checksum (filled by fix-rom)
dd 0 ; device identifier
dw .vendor ; manufacturer string
dw .product ; product name string
db 0,0,0 ; device type string
db 0x20 ; device indicator, bit for "read cacheable" set
dw 0 ; boot connection vector
dw 0 ; boot disconnect vector
dw start ; bootstrap entry point
dw 0 ; reserved
dw 0
.vendor:
db "Nero", 0
.product:
db "2B", 0
align 16
optrom_init:
push di
push es
xor ax, ax
mov es, ax
mov di, 0x0060 ; vector (0x18 * 4 bytes)
mov ax, start
stosw
mov ax, cs
stosw
pop es
pop di
retf
start:
call intr_init
sti
mov si, 0x0000
mov ds, si
.loop:
push bx
mov dx, 0x0000
mov ah, 0x02
mov bx, 0x0000
int 0x10
pop bx
call dump
mov ah, 0x01
int 0x21
cmp al, 0x30
jne .notup
sub bx, 0x0100
.notup:
cmp al, 0x31
jne .notdown
add bx, 0x0100
.notdown:
jmp .loop
.halt:
hlt
jmp .halt
dump:
mov si, bx
mov cx, 0x10
.nextline:
mov ax, si
call kprint16
mov al, 0x3A
call kputc
mov al, 0x20
call kputc
push cx
mov cx, 0x0020
.bytes:
lodsb
call kprint8
loop .bytes
pop cx
mov al,0x20
call kputc
mov al,0x0A
call kputc
mov al,0x0D
call kputc
loop .nextline
ret
%include "intr.asm"
%include "debug.asm"
%include "kprintf.asm"
%include "dosapi.asm"
_reloc_end:
align 512