rdos/nbp.asm

60 lines
983 B
NASM

; assumptions about the starting envionment
cpu 8086
org 0x0000
; es:bx pxeenv+ structure
; ss:sp functional stack
_startup:
xor ax, ax
mov ax, cs
cmp ax, 0x0000 ; MBR or NBP, CS=0000 IP=7C00
je .mbr
cmp ax, 0x07C0 ; MBR on weird BIOS, CS=07C0 IP=0000
je .mbr
.dos:
mov ax, cs
push ax ; return CS
mov ax, .dosret
add ax, 0x0100
push ax ; return IP
mov ax, cs
add ax, 0x0010
push ax ; main CS
mov ax, main
push ax ; main IP
retf
.dosret:
int 0x20
int 0x18
.mbr:
mov ax, 0x0050
mov ds, ax
mov [0xFFFE], ss ; save current stack configuration onto new stack
mov [0xFFFC], sp
mov ss, ax
mov sp, 0xFFFC
push dx
push bx ; possible far ptr to pxeenv+ struct
push es
mov es, ax ; 0x0050
mov di, 0x0000
xor ax, ax
mov ds, ax
mov si, 0x7C00
mov cx, _reloc_end
rep movsb
call 0x0050:main
.halt:
hlt
jmp .halt
%include "kernel/main.asm"
_reloc_end: