I think that values in BPB will still be wrong, as we don't know if BIOS uses actual CHS values.
Maybe it is better to use int 0x13 / ah=0x08 to see what BIOS thinks about CHS.
Then, you will need to use a LBA->CHS algorithm, based on returned from int 0x13 values.
Code: Select all
.get_parameters:
mov dl, byte [bootdev]
mov ah, 08h
int 13h
and cx, 3Fh ; save max sectors
mov [maxsect], cx
add dh, 1 ; save max heads
mov byte [maxhead], dh
.calculate_sector:
mov ax, word [lba] ; get lba sector
mov dx, 0
div word [maxsect] ; divide lba with max sectors
add dl, 1 ; take the remainder, sectors start at 1
mov cl, dl ; sector is in cl
.calculate_head:
mov ax, word [lba] ; get lba sector
mov dx, 0
div word [maxsect] ; divide lba with max sectors
mov dx, 0
div word [maxhead] ; divide quotient with heads
mov dh, dl ; take the remainder, head is in dh
.calculate_cylinder:
mov ch, al ; take the quotient, cylinder is in ch
I hope it will help you, but please, don't copy-paste!