How to programm floppy disk controller

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
yee1
Member
Member
Posts: 42
Joined: Sun Feb 10, 2013 4:02 pm

How to programm floppy disk controller

Post by yee1 »

Hey,
I want to write/read floppy disks. I have 2 computers:
- notebook with usb floppy drive, like http://tiny.cc/rnbg3w
- standard "big" computer (dunno how to call it) with floppy drive like http://tiny.cc/bpbg3w

I have found out that writing to floppy disk in floppy drive is possible using BIOS interrupt (13h) for AH=03h

Ref to http://en.wikipedia.org/wiki/INT_13H#IN ... s_To_Drive i have written code to write my data from buffer to first floppy's sector (tasm):

Code: Select all

bufor db 512 dup (0)

...
; filling bufor with my data i want to be placed at floppy disk
...

mov ax, ds
mov es, ax
mov bx, offset bufor

mov ah, 3h
mov al, 1
mov ch, 0
mov cl, 1
mov dh, 0
mov dl, 0 ; here i specify drive=0, how to detect my floppy drive ?
int 13h
Well it seems to be OK, but i don't know how to use it ;) I haven't tested it either because I don't know how to.

My doubts:
I specify drive number by DL at above interrupt.
There is data table with such info http://en.wikipedia.org/wiki/INT_13H#Drive_Table
So... there is no problem with standard floppy drive ( http://tiny.cc/bpbg3w ).
But what if I use USB Floppy Drive ( http://tiny.cc/rnbg3w ) ? Hot to define it in that way ?
h0bby1
Member
Member
Posts: 240
Joined: Wed Aug 21, 2013 7:08 am

Re: How to programm floppy disk controller

Post by h0bby1 »

there are two set of bios function to access storage device, there is the one you are using which is CHS (cylinder head sector) , and is mostly only used for floppy today, or maybe very old hard drives, and the other api of the bios is the extended api that deal with LBA (logical block addressing), and use a structure to pass parameters to the interupt routine.

in the two set, ah is the number of the function to be called, and dl the number of the drives, drive 00 and 01 are always floppies, hard drives are generally 0x80,0x81 , usb stick and cd rom are 0xE0, 0xE1, the use of other register vary

you can detect some feature with other functions, there is also a chs and extended version of the interupt to detect geometry and information of the disks

http://forum.osdev.org/viewtopic.php?f=1&t=27075 i have posted the source of my bootloader here (it's the second source code listing), it check for all device present in the bios for an iso filesystem, and support the two mode (chs and lba) and detection
Post Reply