Sector reading in ASM with C

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
Jonny K
Posts: 2
Joined: Sat Dec 10, 2005 12:00 am

Sector reading in ASM with C

Post 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
Da_Maestro
Member
Member
Posts: 144
Joined: Tue Oct 26, 2004 11:00 pm
Location: Australia

Re: Sector reading in ASM with C

Post 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
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
Jonny K
Posts: 2
Joined: Sat Dec 10, 2005 12:00 am

Re: Sector reading in ASM with C

Post by Jonny K »

Thanks, but umm, I need to know how to actually read a sector :|


Jonny
Da_Maestro
Member
Member
Posts: 144
Joined: Tue Oct 26, 2004 11:00 pm
Location: Australia

Re: Sector reading in ASM with C

Post 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
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
User avatar
deadmutex
Member
Member
Posts: 85
Joined: Wed Sep 28, 2005 11:00 pm

Re: Sector reading in ASM with C

Post by deadmutex »

try http://www.osdever.net/cottontail/
it has almost everything one would need.
Post Reply