943,673 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 839
  • C RSS
Dec 30th, 2008
0

Controlling Floppy Disk Head using C

Expand Post »
Hi All,
I am researching writing a program in C that will allow me to control the read/write on a FDD and then to move onto HDD's. I have been given some code that will allow me to do this by one of my lecturers but uses the DOS.H library which the commands for controlling and storing data in the general purpose registers AH,AL,CX and DX are now redundant as i understand they were not carried forward onto 32-bit processor architecture for whatever reason.
While trying to look for a solution to this i noticed something about using Assembler code within the C (inline) to control the registers but i am wondering what is the best way to go about doing this. I am not looking for a program that already does this as it would defeat the point and not aid in my understanding.
If i were to use assembler code within the C would i be able pass through values that would allow me to write a file from a hard disk into specific sectors on a floopy? For the project i'm doing i cannot use the standard fwrite or fprintf functions available because i need to do it without the file system (FAT) being corrupted. Any help or links would be greatly appreciated.
Thanks,
Dinklebaga
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dinklebaga is offline Offline
7 posts
since Dec 2008
Dec 30th, 2008
0

Re: Controlling Floppy Disk Head using C

Well the first thing you need to tell us is which OS you're using, and which compiler.

As you've already discovered, this kind of direct access to the hardware is highly specific to your own circumstances.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Dec 30th, 2008
0

Re: Controlling Floppy Disk Head using C

Sorry Salem but the system i need to build on is on multiple OS's but so far i have worked on Linux and Windows XP using a MinGW C compiler.
Thanks
Dinklebaga
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dinklebaga is offline Offline
7 posts
since Dec 2008
Dec 31st, 2008
0

Re: Controlling Floppy Disk Head using C

Conceptually, you'll need 4 files.

main.c - the portable part of your application, and #includes port.h
port.h - your abstracted interface to your floppy, with say move_head(int track);
port_win32.c - implements move_head(int track) and the rest of the API, for win32
port_linux.c - implements move_head(int track) and the rest of the API, for linux. If possible, try to do this using the POSIX API as much as possible. It'll save time when moving to other POSIX systems.

When you build a system, you choose (in your project / makefile) the appropriate port_xxx.c for the environment in which you're working.

Do you have specific questions for specific platforms still?
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Jan 3rd, 2009
0

Re: Controlling Floppy Disk Head using C

You are suggesting using the POSIX API's as much as possible but as far as i know these aren't supported within the MinGW Compiler for windows, would it be preferable to change the compiler i have to Cygwin which does or are there ways round this on the Windows based system?
Thanks,
Dinklebaga
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dinklebaga is offline Offline
7 posts
since Dec 2008
Jan 3rd, 2009
0

Re: Controlling Floppy Disk Head using C

>You are suggesting using the POSIX API's as much as possible
Only for true POSIX systems.

> would it be preferable to change the compiler i have to Cygwin which does
I dunno - that's for you to research.
From what you describe, it might be pushing it too much.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Jan 3rd, 2009
0

Re: Controlling Floppy Disk Head using C

Many thanks for your help Salem
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dinklebaga is offline Offline
7 posts
since Dec 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: changing color of a pushbutton on a dialog box
Next Thread in C Forum Timeline: Need Help..!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC