Home | x86 Assembly | <<< Previous | Next >>> |
Reading from disk, directly Using BIOS interrupt 13h, you can read from disks. Set the registers as on the right, and execute the interrupt. For reading, we use AH=02h, and for writing AH=03h Please note that you might be in danger of damaging your disk if something is done in the wrong way. Begin with floppy disks. Experiment on them before trying it on Hard Disks. |
AH = 02h (for reading)
AL = number of sectors to read (must be nonzero) CH = low eight bits of cylinder number CL = sector number 1-63 (bits 0-5) high two bits of cylinder (bits 6-7, hard disk only) DH = head number DL = drive number (bit 7 set for hard disk) ES:BX points to data buffer |
Data on a disk is organized as follows: A disk is divided into tracks and sectors, and each disk has some read/write heads. These heads are small hardware units that write directly to the surface of the disk. Data is written to the disk through the use of disk heads. Floppy disks have two heads labeled 0 and 1 Cylinders (or tracks) are labeled from 0 to 79 Sectors are labeled from 1 to 18 Data is stored in individual sectors in the following order: LBA# 1 cylinder0 head 0 sector 1 LBA# 2 cylinder0 head 0 sector 2 ...and so on......... till maximum number of sectors is reached. LBA# 18 cylinder0 head 0 sector 18 (this is the case on floppy) the head variable is incremented now: LBA# 19 cylinder0 head 1 sector 1 ...and so on ......... LBA# 36 cylinder0 head 1 sector 18 ....now, the head is set to 0 again and cylinder is incremented LBA# 37 cylinder1 head 0 sector 1 one important point to keep in mind is that there is no sector 0, while there exist cylinder 0 and head 0. In order to read or write a disk you must know what head, cylinder and sector to use. This creates problems with Linear Block Addressing (LBA). You can figure out what LBA numbers are if you look above. LBA is the sequence number of Cylinder, Head, and Sector group (also called CHS). |
Home | x86 Assembly | <<< Previous | Next >>> |