Convert from/to CHS-LBA
Posted: Mon Apr 02, 2007 5:15 am
I have the following formulas to convert CHS-to-LBA and LBA-to-CHS. I think they are right because they seem to work fine with floppies:
-----------------------------
Now the question is: Will those formulas work seamlessly both for any capacity floppies, and even for ATA disks that are addressed using CHS?
Or are there another many CHS-to-LBA-to-CHS conversion formulas I should need to know, that somebody knows about?
Code: Select all
CHS_to_LBA = (((Sectors_Per_Track*NumHeads)*Track)+(Sectors_Per_Track*Head)+Sector)-1;
Code: Select all
Cylinder = (int)(LBA/(Sectors_Per_Track*NumHeads));
Head = (int)(LBA/Sectors_Per_Track)%NumHeads;
Sector = (int)(LBA%Sectors_Per_Track)+1;
Now the question is: Will those formulas work seamlessly both for any capacity floppies, and even for ATA disks that are addressed using CHS?
Or are there another many CHS-to-LBA-to-CHS conversion formulas I should need to know, that somebody knows about?