accessing hardware directly - how/why to do it?

Special K

Diamond Member
Jun 18, 2000
7,098
0
76
I read about it in the sams C book, but they said it was beyond the scope of the book, and didn't give any details. Why would you want to do it? How do you do it? Is that what the volatile keyword is for (or related to)? Doesn't winnt not allow it anyway?
 

BCYL

Diamond Member
Jun 7, 2000
7,803
0
71
One of the reason you wanna do it is if you are writing device drivers... Most of the OS's are written in C & assembly, therefore most device drivers are written in C as well... that's why your C book mentioned accessing the hardware directly...

But if you are simply writing an application running on top of an OS, you dont need (and not recommended) to access the hardware... instead you should access it through the device driver...
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
As an application write you never want to access the hardware directly, the OS provides syscalls, ioctls, etc so that you don't have to. Most of the time you can't, the OS will kill the program or throw some other exception if you try.

As BCYL said the only time you should worry about the hardware is when you're writing the driver for it, otherwise you'll just limit yourself to a small set of hardware or have your code entagled with tons of workarounds and fixes that normally are handled by the device driver without you knowing.