Instead of adjusting CS, always relocate NBP to 0x00500

This commit is contained in:
Nero 2019-03-23 20:37:18 +00:00
parent 1005a24c7f
commit 5becc89872

40
nbp.asm
View File

@ -1,38 +1,26 @@
; assumptions about the starting envionment ; assumptions about the starting envionment
cpu 8086 cpu 8086
org 0x0000 org 0x0000
; dl probable drive number ; es:bx pxeenv+ structure
; ds:si probable pointer to partition structure
; es:bx probable pxeenv+ structure
; ss:sp functional stack ; ss:sp functional stack
_startup:
; during PXE, CS=0000 and IP=7C00 ; during PXE, CS=0000 and IP=7C00
; adjust CS so our offsets match org setting above _startup:
mov ax, _exit xor ax, ax
push ax ; store exit addr on stack so main will return to it mov ss, ax
push bx ; backup bx mov sp, 0x0000
call near .push_ip mov ds, ax
.push_ip: mov es, ax
pop bx
sub bx, .push_ip ; subtract expected value ... mov si, 0x7C00
shr bx,1 ; shift it to 4 bits to the right mov di, 0x0500
shr bx,1 mov cx, (_reloc_end)
shr bx,1 rep movsb
shr bx,1 jmp 0x0050:main
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: _exit:
mov si, .message mov si, .message
call kprintf call kprintf
int 0x20
.loop: .loop:
hlt hlt
jmp .loop jmp .loop
@ -40,3 +28,5 @@ _exit:
db "Halted: Waiting for poweroff...", 0 db "Halted: Waiting for poweroff...", 0
%include "kernel/main.asm" %include "kernel/main.asm"
_reloc_end: