Given the code below, the problem isn't necessarily in the transition itself; there are some possible problems that could cause the disk read to silently fail. First, the code given does not doesn't set the value of DL, which is the parameter which indicates which drive to read; I am assuming it is set earlier on, but since it isn't shown, I have no way of being sure. Similiarly, the code as shown does not initialize the disk controller, though it presumably is earlier on. The real problem is that this code doesn't check for an error code to make sure that the disk reads properly. This should be a simple test and loop on the value of carry flag, but there's a catch: the FDC shoud be reset before each attempt.
The following code should ensure that it works correctly:
Code: Select all
lResetDisk:
mov dl, [BootDrive] ; assumes you saved the Disk ID to BootDrive earlier
xor ah, ah ; clear AH
mov al, BIOS_RESETDISK
int BIOSINTERRUPT
jc short lResetDisk ; if there is an error, loop and try again
lReadDisk:
mov ax, 0
mov es, ax
mov bx, KERNELPOSITION ; es:bx
mov ah, BIOS_READDISK
mov al, KERNELLENGTH
mov ch, 0 ; Track
mov cl, 2 ; Start sector
mov dh, 0 ; Head
int BIOSINTERRUPT
jc short lResetDisk ; if there is an error, reset the FDC and try the read again
jmp KERNELPOSITION
Note that this code, as written, will loop indefinitely until the drive works; this could be a serious problem with a very flakey FDD or disk.
As for the jump itself, it is not technically necessary to use a FAR jump if the kernel offset is in the same segment as that of the boot loader; however, if this is the case, you'll have to make sure that the kernel code itself is [tt][[ORG KERNELPOSITION]][/tt], or else the label offsets for the kernel code will be wrong and the code will fail. I would argue that it wiser to set ES to a convienent segment base, use [tt][[ORG 0x0000]][/tt] in the kernel code, load the kernel at ES:0x0000, and JMP FAR th that location (or, as I do in my code, push ES and then 0x000 and RETF).
If it helps at all, you can see an early version of my own boot loader in
this thread. I hope this helps you work out the problem. Note that in this version, rather than repeatedly trying to get it to work, it simply fails and prints an error, which is acceptable but not very fault-tolerant.