diff --git a/boot/fat32.asm b/boot/fat32.asm index 437c53b..60dad99 100644 --- a/boot/fat32.asm +++ b/boot/fat32.asm @@ -1,5 +1,6 @@ ; Bootsector for FAT32 filesystems org 0x0800 + cpu 8086 jmp short init nop @@ -28,12 +29,17 @@ dn: equ ( $$ + 0x040 ) times (0x5A - ($-$$)) db 0 init: xor ax, ax - mov ds, ax - mov es, ax mov ss, ax mov sp, 0x7C00 - mov si, sp + ; save potential partition table entry + push ds + push si + + mov ds, ax + mov es, ax + + mov si, 0x7C00 mov di, 0x0800 mov cx, 0x0100 rep movsw @@ -101,7 +107,7 @@ read_: ; read sector DX:AX from disk mov si, sp mov ah, 0x42 - mov dl, 0x80 + mov dl, [dn] stc int 0x13 jc dskerr @@ -213,7 +219,8 @@ loadf: call search mov dx, [si+0x14] jmp load -main: ; load root directory +main: mov [dn], dl + ; load root directory call loadr ; search for first system directory mov ah, 0x14 @@ -222,6 +229,20 @@ main: ; load root directory mov ah, 0x04 call loadf ; jump + xor ax, ax + xor cx, cx + xor dx, dx + xor bx, bx + xor di, di + xor bp, bp + + ; restore drive number + mov dl, [dn] + + ; restore potential partition table + pop si + pop ds + jmp 0:0x7C00 end: call msg