CHS conversion

CHS conversion

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).

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.

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.

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

External Links

* [http://www.viralpatel.net/taj/tutorial/chs_translation.php CHS to LBA Translation Tutorial]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Conversion — may refer to: Contents 1 Economy and Finance 2 Law 3 Marketing 4 Religion 5 Sport …   Wikipedia

  • Cylinder-head-sector — Cylinder head sector, also known as CHS, was an early method for giving addresses to each physical block of data on a hard disk drive. In the case of floppy drives, for which the same exact diskette medium can be truly low level formatted to… …   Wikipedia

  • Список алгоритмов — Эта страница информационный список. Основная статья: Алгоритм Ниже приводится список алгоритмов, группированный по категориям. Более детальные сведения приводятся в списке структур данных и …   Википедия

  • List of algorithms — The following is a list of the algorithms described in Wikipedia. See also the list of data structures, list of algorithm general topics and list of terms relating to algorithms and data structures.If you intend to describe a new algorithm,… …   Wikipedia

  • Logical Block Addressing —  Cet article concerne la méthode d’adressage informatique. Pour d’autres sens de l’abréviation, voir LBA. L’adressage en LBA (abréviation de Logical Block Addressing en anglais soit « Adressage par bloc logique » en français) est… …   Wikipédia en Français

  • Logical block addressing — Le LBA, ou Logical Block Addressing (« Adressage par bloc logique », en anglais) est historiquement un moyen d’adresser les secteurs d un disque dur. Cette méthode d’adressage a ensuite été généralisée à un grand nombre de médias de… …   Wikipédia en Français

  • Cylinder/Head/Sector — Cylindre/Tête/Secteur  Cet article concerne la méthode d adressage informatique. Pour d autres sens de l abréviation, voir CHS. L adressage en CHS (abréviation de Cylinder/Head/Sector en anglais soit « Cylindre/Tête/Secteur » en… …   Wikipédia en Français

  • Cylindre/Tête/Secteur —  Cet article concerne la méthode d adressage informatique. Pour d autres sens de l abréviation, voir CHS. L adressage en CHS (abréviation de Cylinder/Head/Sector en anglais soit « Cylindre/Tête/Secteur » en français ; l… …   Wikipédia en Français

  • Histoire de l'homme occidental — L’histoire de l’homme occidental est l’étude des faits qui concernent l’identité culturelle de l’homme occidental à travers son histoire. Elle évacue toute composante événementielle dans le but d’illustrer comment ce dernier a évolué dans ses… …   Wikipédia en Français

  • Advanced Technology Attachment Peripheral Interface — Integrated Drive Electronics …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”