Page 1 of 1

DIsk IO

Posted: Sat Nov 01, 2003 12:00 am
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.

RE:DIsk IO

Posted: Sun Nov 02, 2003 12:00 am
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.

RE:DIsk IO

Posted: Sun Nov 02, 2003 12:00 am
by edy42
So if that can only be done in real mode, how do you read and write to disks in protected mode? Thanks.

RE:DIsk IO

Posted: Sun Nov 02, 2003 12:00 am
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

RE:DIsk IO

Posted: Mon Nov 03, 2003 12:00 am
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.