int 0x13 mov ah, 0x02 mov dl,0x00 (floppy)

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
GeGuNa
Posts: 12
Joined: Sun Apr 02, 2017 11:43 am

int 0x13 mov ah, 0x02 mov dl,0x00 (floppy)

Post by GeGuNa »

hello everyone , i have one question ,

how to read all sectors in the floppy disk (usb/cd-dvd/usb) (1.44/2.88/360/720) ?

sorry for my bad english ...
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: int 0x13 mov ah, 0x02 mov dl,0x00 (floppy)

Post by BenLunt »

Hi,

Since you have stated in the subject line, int 0x13, I will assume that you mean using the BIOS.

First, using Ralf Browns Interrupt list or another reference, look at service 0x02:

Code: Select all

AH = 02h
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 -> data buffer
Please note that you can only read from a single track at a time. You must not assume that the BIOS will increment the C/H/S values and read past the End of the Track (EOT).

It is best to code your driver/boot sector/whatever to use LBA addressing and then at the "read" level, convert to CHS values. This way you can keep track of sectors as 0,1,2,3,4,5,...2879 instead of 0/0/1, 0/0/2, 0/0/3, ... 0xFF/0xFF/0xFF.

Ben
- http://www.fysnet.net/media_storage_devices.htm
azblue
Member
Member
Posts: 147
Joined: Sat Feb 27, 2010 8:55 pm

Re: int 0x13 mov ah, 0x02 mov dl,0x00 (floppy)

Post by azblue »

Use functions 48h and 8h to get drive parameters (so you know how big your drive is).

Here's how you convert LBA to CHS:
C = LBA ÷ (HPC × SPT)
H = (LBA ÷ SPT) mod HPC
S = (LBA mod SPT) + 1

If you're rolling your own bootloader you'll want to become familiar with Ralf Brown's Interrupt List:
http://www.ctyme.com/rbrown.htm
Post Reply