Allow pc86 bootloader to boot from more floppy drives.

When the bootloader probes the drive geometry, the BIOS can clobber the
es register.  If this happens, the bootloader loads the program to the
wrong address, and jumps off the code.  This happens with an emulated
floppy drive in Bochs or QEMU, but not with an emulated hard disk.
This commit is contained in:
George Koehler 2012-09-23 14:43:22 -04:00
parent e7c79415b5
commit 3dcc3bd1cf

View file

@ -23,7 +23,7 @@
! If you ever need to change the boot code, this needs adjusting. I recommend ! If you ever need to change the boot code, this needs adjusting. I recommend
! a hex editor. ! a hex editor.
PADDING = 0xB9 PADDING = 0xB7
! Some definitions. ! Some definitions.
@ -45,8 +45,8 @@ start2:
mov ax, cs mov ax, cs
mov ds, ax mov ds, ax
mov es, ax
mov ss, ax mov ss, ax
! Defer setting es until after probing the drive.
! Initialise the stack, which will start at the top of our segment and work ! Initialise the stack, which will start at the top of our segment and work
! down. ! down.
@ -65,10 +65,13 @@ start2:
call write_string call write_string
! Probe the drive to figure out its geometry. ! Probe the drive to figure out its geometry.
! This might clobber es.
push dx push dx
mov ax, 0x0800 ! service number mov ax, 0x0800 ! service number
int 0x13 int 0x13
mov ax, cs ! restore es
mov es, ax
pop ax pop ax
jc cant_boot jc cant_boot