[help]LBA to CHS function
Posted: Wed Jan 12, 2011 10:11 pm
I try to load my loader on my boot loader 32 bit with FAT32. But my LBACHS function do not work properly. LBA to CHS formula is:
absolute sector = (logical sector / sectors per track) + 1
absolute head = (logical sector / sectors per track) MOD number of heads
absolute track = logical sector / (sectors per track * number of heads)
I try to load my root directory which is locate on LBA sector 0x2000 to memory 0:0x8000.
On BPB my sector per track is 0x3f and number of head is 0xffh.
From the formula it must be C=0 H=0x82 and S=3, but my function show C=0x82 H=3 S=0x82
here is my LBACHS code
Can someone tell me what's wrong on the function?
Thanks, best regards
absolute sector = (logical sector / sectors per track) + 1
absolute head = (logical sector / sectors per track) MOD number of heads
absolute track = logical sector / (sectors per track * number of heads)
I try to load my root directory which is locate on LBA sector 0x2000 to memory 0:0x8000.
On BPB my sector per track is 0x3f and number of head is 0xffh.
From the formula it must be C=0 H=0x82 and S=3, but my function show C=0x82 H=3 S=0x82
here is my LBACHS code
Code: Select all
; PROCEDURE LBACHS
; convert "ax" LBA addressing scheme to CHS addressing scheme
; absolute sector = (logical sector / sectors per track) + 1
; absolute head = (logical sector / sectors per track) MOD number of heads
; absolute track = logical sector / (sectors per track * number of heads)
;*************************************************************************
LBACHS:
xor dx, dx ; prepare dx:ax for operation
div WORD [A_BF_BPB_SectorsPerTrack] ; calculate
inc dl ; adjust for sector 0
mov BYTE [absoluteSector], dl
xor dx, dx ; prepare dx:ax for operation
div WORD [A_BF_BPB_Heads] ; calculate
mov BYTE [absoluteHead], dl
mov BYTE [absoluteTrack], al
ret
Thanks, best regards