ebooksgratis.com

See also ebooksgratis.com: no banners, no cookies, totally FREE.

CLASSICISTRANIERI HOME PAGE - YOUTUBE CHANNEL
Privacy Policy Cookie Policy Terms and Conditions
CHS conversion - Wikipedia, the free encyclopedia

CHS conversion

From Wikipedia, the free encyclopedia

CHS conversion is a conversion between the geometric coordinate (cylinder/head/sector or CHS) of data on a disk's surface and the addressing system used by the disk's filesystem (linear base address or LBA). This conversion process is used with floppy disks as well as hard disks but this article will focus on its use with floppy disks.

When accessing data on a disk via the IBM PC's floppy disk controller, the driver must describe the location of that data in terms of its CHS coordinates. These coordinates are specified using three dimensions: cylinder number, head number and sector number.

The addressing method used by almost all modern filesystems is called logical block addressing (LBA). In logical block addressing, only one number is used to address data, rather than three. Each linear base address describes a single block. The reason for using LBA instead of CHS in the filesystem is because of its simplicity. Most modern floppy disks contain 2,880 blocks (numbered 0 to 2,879).

[edit] From CHS to LBA

The equation to convert from CHS to LBA follows:

LBA = ( ( CYL * HPC + HEAD ) * SPT ) + SECT - 1

Where:

 LBA: linear base address of the block
 CYL: value of the cylinder CHS coordinate
 HPC: number of heads per cylinder for the disk
HEAD: value of the head CHS coordinate
 SPT: number of sectors per track for the disk
SECT: value of the sector CHS coordinate

This equation is not used very often. Usually the software already has the LBA value and needs to calculate the CHS value for it.

[edit] From LBA to CHS

The equations to convert from LBA to CHS follow:

 CYL = LBA / (HPC * SPT)
TEMP = LBA % (HPC * SPT)
HEAD = TEMP / SPT
SECT = TEMP % SPT + 1

Where:

 LBA: linear base address of the block
 CYL: value of the cylinder CHS coordinate
 HPC: number of heads per cylinder for the disk
HEAD: value of the head CHS coordinate
 SPT: number of sectors per track for the disk
SECT: value of the sector CHS coordinate
TEMP: buffer to hold a temporary value

This equation is used very often by operating systems such as DOS to calculate the CHS values it needs to send to the disk controller or INT13h in order to read or write data.

[edit] Assembler code example

The following procedure calculates the geometric coordinate of a block of data based on an LBA address specified. Only works when AX is enough to hold LBA.

GetCHS proc
            mov         AX, LBA
            xor         DX, DX
            mov         BX, SPT
            div         BX
            inc         DX
            mov         SECT, DL
            xor         DX, DX
            mov         BX, HPC
            div         BX
            mov         CYL, AL
            mov         HEAD, DL
            ret 
GetCHS endp


aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -