From fe42e9145ae1b4713dcfb9cc211841317725c3e4 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Sun, 15 Sep 2019 19:49:58 +0000 Subject: [PATCH] fatvbr: correctly setup segment registers --- boot/fatvbr.asm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/boot/fatvbr.asm b/boot/fatvbr.asm index 4858eba..70059cf 100644 --- a/boot/fatvbr.asm +++ b/boot/fatvbr.asm @@ -63,6 +63,7 @@ init: mov ax, (psp >> 4) mov ss, ax xor sp, sp + push sp ; Relocate from [prog] to [self] xor ax, ax @@ -110,16 +111,25 @@ main: mov bp, 0x3332 jc error - ; setup int 19h call at 0000, and push its address to stack + ; setup int 19h call if prog returns mov WORD [psp], 0x19CD - push sp - ; clear out registers and jump into target + ; clean registers xor ax, ax xor cx, cx xor dx, dx xor bx, bx + + ; restore boot drive number mov dl, [fdc.drv] + + ; setup segment registers + push ss + pop ds + push ss + pop es + + ; jump into target jmp 0x07B0:0x0100 ; Read sectors from disk