rdos/main.asm

70 lines
1.2 KiB
NASM

; assumptions about the starting envionment
cpu 8086
org 0x0000 ; if we are not at CS:0000, CS adjustment will fix it for us
; dl probable drive number
; ds:si probable pointer to partition structure
; es:bx probable pxeenv+ structure
; ss:sp functional stack
_startup:
; during PXE, CS=0000 and IP=7C00
; adjust CS so our offsets match org setting above
mov ax, _exit
push ax ; store exit addr on stack so main will return to it
push bx ; backup bx
call near .push_ip
.push_ip:
pop bx
sub bx, .push_ip ; subtract expected value ...
shr bx,1 ; shift it to 4 bits to the right
shr bx,1
shr bx,1
shr bx,1
mov ax,cs
add ax,bx ; so we can add it to cs
pop bx ; restore bx
push ax ; cs
mov ax, main
push ax ; ip
sti
retf ; jump
_exit:
mov si, .message
call kprintf
int 0x20
.loop:
hlt
jmp .loop
.message:
db "Halted: Waiting for poweroff...", 0
main:
mov ax, cs
mov ds, ax
mov bx, 0x002E
mov dx, debug_reg_ir
call ivt_set
mov ax, 0
mov bx, 0
call cons
mov si, di
call print
ret
%include "intr.asm"
%include "debug.asm"
%include "kprintf.asm"
%include "heap.asm"
%include "cons.asm"
%include "int.asm"
%include "print.asm"
heap:
dw 0