If I want to convert from CHS to LBA there's an expression to calculate it:
LBA = (Cylinder * TotalHeads + SelectedHead) * SectorsPerTrack + (SectorNum - 1)
If I want to access CHS(0, 0, 1) through LBA, replacing in that expression I'll have:
LBA 0 = (0 * 16 + 0) * 63 + (1 - 1)
Is that LBA 0 absolute or relative ?
If I want to read, for example 3 sectors, do I need to calculate all the LBAs?
Example:
Reading 3 sectors starting CHS(0, 1, 1):
LBA 63 = (0 * 16 + 1) * 63 + (1 - 1)
LBA 64 = (0 * 16 + 1) * 63 + (2 - 1)
LBA 65 = (0 * 16 + 1) * 63 + (3 - 1)
And one more question:
To send that to LBA ports (0x1f3-0x1f5 (LBA High)) I need to get the result of that expression right?
Example:
Code: Select all
;ECX holds value 63 (from LBA 63)
inc edx ;dx is now 0x1f3 - LBAlo
mov al, cl ;cl has LBA
out dx, al
inc edx ;dx is now 0x1f4 - LBAmid
mov al, ch ;highest of 8 bits value
out dx, al
inc edx ;dx is 0x1f5 the LBAhi
bswap ecx ;swap the bits, cl will have bits 24-28 and ch will have bits 16-23
mov al, ch ;put it in al
out dx, al