DIsk IO

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
edy42

DIsk IO

Post by edy42 »

I am new at OS Programming, and do not know a whole lot about about x86 Assembly. I have been trying to access read data from a floppy drive using the following code (compiled with GCC):
asm(" movb $2, %ah
movb $4, %al
movb $0, %ch
movb $2, %cl
movb $0, %dh
movb $0, %dl
movw buffer, %bx
movw %bx, %es
mov $0, %bx
int $0x13
buffer: .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
");
It compiles correctly, but when I run it in the emulator Bochs, it exits and says:
Bochs is exiting with the following message:
[CPU  ] exception(): 3rd (13) exception with no resolution

I do not have any idea about diskio or anything like that. Thanks.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

RE:DIsk IO

Post by df »

gcc creates 32 bit flat code. pmode for x86. your trying to call a real mode interrupt that does not exist in protected mode.
-- Stu --
edy42

RE:DIsk IO

Post by edy42 »

So if that can only be done in real mode, how do you read and write to disks in protected mode? Thanks.
carbonBased

RE:DIsk IO

Post by carbonBased »

With ports (PIO) or dma or real mode interrupt 0x13 inside of a vm86 task handler (which, essentially, emulates real mode in a protected environment (with a performance penalty, of course)).

Cheers,
Jeff
Schol-R-LEA

RE:DIsk IO

Post by Schol-R-LEA »

While it is possible to run it by switching from protected mode back to real mode, or in a virtual mode task, the best solution is to write your own disk drivers; the same applies to device drivers in general.

If you check the development links (especially the Operating Systems Resource Center), you should find tutorials on how low-level disk I/O works for both floppy and hard drives.
Post Reply