Page 1 of 1
Sector reading in ASM with C
Posted: Sat Dec 10, 2005 12:00 am
by Jonny K
Hi,
I'm using inline ASM in C, and I'm wondering how I can get the variable 'test' to contain a whole sector from a floppy disk.
Any ideas?
Jonny
Re: Sector reading in ASM with C
Posted: Mon Dec 12, 2005 12:00 am
by Da_Maestro
1. Make 'test' an array of 512 bytes.
2. Load the sector into the address of 'test'
3. Voila
If you want the memory address to be mapped to the sector on the disk and updated with reads/writes...that's way too complicated for your every day homebrew os :-p
Re: Sector reading in ASM with C
Posted: Mon Dec 12, 2005 12:00 am
by Jonny K
Thanks, but umm, I need to know how to actually read a sector
Jonny
Re: Sector reading in ASM with C
Posted: Mon Dec 12, 2005 12:00 am
by Da_Maestro
Ok well that's a different question alltogether.
It depends on whether you are running in real-mode or protected-mode.
In real mode this is as easy as using the BIOS. However when you do this you loose the ability to switch to a different task while the disk is being read.
For this and for protected-mode it is recommended that you access the disk hardware directly. There is plenty of sample code available, and intels documentation on their floppy disk controller is pretty good.
I can't refer you to any links...I'm posting from work
Anyone else know anywhere you can find manuals/references/code?
Adam
Re: Sector reading in ASM with C
Posted: Tue Dec 13, 2005 12:00 am
by deadmutex
try
http://www.osdever.net/cottontail/
it has almost everything one would need.