I'm just starting my own bootloader and I can't seem to be able to load the second sector of a floppy to memory.
This code worked and somehow it just stoped working after some change which I don't remember.
Can you please look at the code and tell me what I am doing wrong?
I have checked the code dozens of times and it looks like it should work fine.
I also have this at the top of the file:
Code: Select all
bits 16 ; set the mode to 16 bit
org 0x7C00 ; the bootloader is loaded into 0x7c00
jmp blStart ; jump over OEM block
Code: Select all
blStart:
; Reset floppy
blResetFloppy:
xor ah, ah ; use function 0x0 to reset floppy
xor dl, dl ; drive 0 is floppy drive
int 13h ; call BIOS
jc blResetFloppy ; If Carry Flag (CF) is set, there was an error. Try resetting again
; Done Reset
; Read second sector from floppy to 0x7E00:0
mov ax, 0x7E00 ; put 0x7E00 temporarily in ax
mov es, ax ; set es to 0x7E00
xor bx, bx ; set bx to 0
blReadSecondSector:
mov ah, 02h ; use function 0x02
mov al, 1 ; read 1 sector
mov ch, 1 ; its still on track 1(cylinder 1)
mov cl, 2 ; read the second sector
xor dx, dx ; use head 0 to read and read from drive 0(floppy drive)
int 13h ; read sectors
jc blReadSecondSector ; If Carry Flag (CF) is set, there was an error. Try reading again
; jump to the loaded sector
jmp 0x7E00:0x0
; Fill the file with zeros to fit into a whole section(512 bytes)
times 510-($-$$) db 0
dw 0xAA55 ; Boot sector identifyer
; sector 2 - second bootloader part ----------------------------------------------------------------------------------------------
mov ax, 0
int 10h
cli
hlt
times 1024-($-$$) db 0
While debugging with functions that print out messages using bios it resets and reads fine ut I don't know if it's reading what it's supposed to.
Thanks