how to read a sector from floppy without bios interupter

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
frankhuang

how to read a sector from floppy without bios interupter

Post by frankhuang »

How to read a sector from floppy by using IO port,
but without using the bois's interupter,
because my os kernel is in protected mode
Can you give a sample code?

thanks in advance!
Thunder

Re:how to read a sector from floppy without bios interupter

Post by Thunder »

You need to do this with IO ports

Go to http://dev.remo.lt/osdev/index.php?id=13

Here you'll find all info about direct floppy reading. :)
frankhuang

Re:how to read a sector from floppy without bios interupter

Post by frankhuang »

to Thunder:
Thank you very much.
frankhuang

Re:how to read a sector from floppy without bios interupter

Post by frankhuang »

what 's wrong with my code,
it just don't work.

i have a book,it show's that the command bytes
should write to port 0x3f5,but the infomation Thunder
supplied at sit http://dev.remo.lt/osdev/index.php?id=13
tell to write to port 0x3f7.
i really confused ,can someone help me.
the code i wrote for testing as
following(it does not work):

;check if read to transform
mrqloop:
mov dx,03f4h
in al,dx
and al,0c0h
cmp al,080h
jne mrqloop

;start data transform ,read sector
mov al,0E6h
mov dx,3f5h
out dx,al

mov dx,3f7h
mov al,0
out dx,al ;drive A
out dx,al ;Cylinder 0
out dx,al ;head 0
out dx,al ;sector number 0
mov al,2
out dx,al ;sector size 128*2^2
mov al,18
out dx,al ;sector per track
mov al,1bh
out dx,al ;Length of GAP 3
mov al,0ffh
out dx,al ;length

mov cx,512
cld
mov di,offset sectordata
;print the every byte to screen
LRead:
mov dx,3f7h
in al,dx
mov ah,02h
mov dl,al
int 21h
loop LRead
Peter_Vigren

Re:how to read a sector from floppy without bios interupter

Post by Peter_Vigren »

First of all, do you start the floppy's motor and are interrupts enabled?

Second, the Read command leave result bytes on the buffer to be read before the actual data (if no error occured). These result bytes aren't in the buffer before an interrupt (I#6?) has been issued. The interrupt sets the highest bit of the byte at 0x40:0x3E and should be cleared by the program when detected.

I hope you understand something of my pretty bad explanation...
frankhuang wrote: mrqloop:
mov dx,03f4h
in al,dx
and al,0c0h
cmp al,080h
jne mrqloop
You shouldn't, from what I know, need the and/cmp. You should be able to use this instead:

Code: Select all

Test Al,10000000b
Jz mrqloop
Anyone, feel free to correct me.
Post Reply