Floppy Organisation:Format of the 3.5" high density disk
Thought some one might find this information useful:
In bootloaders you may wanna copy your kernel image from your floppy to memory. If your kernel binary image takes like 1MB of space and you transferred them to floppy you have to know how the data is stored over the magnetic medium.
The most popular floppy disk is the IBM's 3.5 inch high density disk. There are many others out there but is not so popular around. Atleast not in my place
Our data is written with the help of magnetic head placed over the coercive magnetic material disk.
Total capacity of this disk is 1440 KB.
The data are stored in sectors. Sectors are stored in a what is called as tracks.
Tracks are circular and concentric on the disk. Our magnetic disk is double sided. So on each side we have concentric tracks.
To read data, 2 heads are used for each side. Each side contains 80 tracks. Each tracks contain 18 sectors.
Each sector can hold 512 Bytes.
So for the total disk: 512 x (18x(80x2))) = 1474560 Bytes = 1440 KB
BIOS Interrupt to transfer floppy content to memory:
Say we have 10 sectors to copy into our memory. The program needed to invoke the BIOS interrupt resides at sector 1(The Boot loader). The 10 sectors that needed to be copied present through sectors 2 to 11.
interrupt 0x13 is used for transferring contents from disk to memory.
There is something called function involved with interrupt 0x13. Each function does a different operation.
I'll just say the function for copying data from floppy to memory.
Our function is 0x02.
AH = Function number
AL = No of sectors to transfer
CH = Track number
CL = Starting sector number
DH = Head number
DL = Drive number
ES:BX -> Data buffer (This is the starting address where our contents from floppy sit on). Linear address = 16 x ES + BX
Return values after completion of the operation:
CF = Error
AH = Status
AL = No of sectors transferred
Example:
mov ax,#0x500
mov es,ax
mov bx,#0
mov dl,#0
mov dh,#0
mov ch,#0
mov cl,#2
mov al,#10
mov ah,#2
int 0x13
jmpi 0,#0x500
The above example is to transfer 10 sectors starting from sector 2 till sector 11 to memory location 0x5000. It doesnt check the error part. We can test the CF to see if there is any error. AH contains the status after completion. 00 if successful.
Please correct me if i am wrong somewhere