Page 1 of 1

disk translation information needed

Posted: Sun Jul 20, 2003 11:26 am
by one
I want to know how i can convert a sector address of a floppy(1.44Mb) to its physical address.I mean i want to use BIOS interrupt 13h function 02h so if i want to read in sector 8(for e.g.) of a floppy disk how should i do so. what values are to be put in the registers and more importantly how the hell do i calculate them for any sector i need.
Any links to relevant pages or info from you wizards would be very
much appreciated.
One

Re:DISK TRANSLATION INFO NEEEDED

Posted: Sun Jul 20, 2003 12:35 pm
by Curufir
I admit my original posts (And Pype's on disk structure) have dropped down a bit, so it's no surprise you didn't find 'em :).

Here's a recap (Search engine won't search on my name :<):

[pre]
;************************************************************************
;* Convert the LBA sector address into CHS scheme so int 13h can use it *
;* HPC = Number of heads/cylinder *
;* SPT = sectors/track *
;* Sector = (LBA mod SPT) + 1 *
;* Head = (LBA / SPT) mod HPC *
;* Cylinder = (LBA / SPT) / HPC *
;************************************************************************

XOR DX, DX
DIV WORD [BPB_SecPerTrk]
INC DX
MOV CL, DL
XOR DX, DX
DIV WORD [BPB_NumHeads]
MOV CH, AL
MOV DH, DL
[/pre]

Assumes AX contains the LBA sector you want to convert. Leaves CL=Sector, CH=Cylinder, DH=Head, it's that way to make it easier to use int 13h.

BPB_SecPerTrk and BPB_NumHeads should be self explanatory. The reason these names are used is they are the relevant ones from the MS white paper on FAT formats which most people get around to reading at some point.