Link to home
Create AccountLog in
Avatar of chsalvia
chsalvia

asked on

Limitations of C++/high level programming

While C++ includes a lot of useful classes, templates and functions, the actual operation of any given algorithm basically comes down to a few keywords, like if, else, for, while, new, delete, etc,.  

Now, with those basic keywords, it seems that almost any imaginable algorithm or procedure is possible.  But isn't there one big exception?  Isn't it basically impossible, using C++ or C, to write code that directly manipulates specific computer hardware such as video cards, ethernet cards, etc?  

I realize there are libraries to do just that, like the C socket library and such, but aren't those libraries written in assembly with machine-specific code?  Wouldn't it be impossible to write a program from scratch, in C++, using ONLY basic C++ keywords and without including inline assembly code, that accesses specific hardware?
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of chsalvia
chsalvia

ASKER

grg99,

>Some other peripherals are accessed through accessing certain special addresses that are not backed by RAM, but by the >peripherals themselves. For these you can access them through most any language that lets you set pointers to point to >arbitray addresses, like C and C++.

So, are you saying that machine-specific hardware can be accessed directly via C/C++ by assigning a pointer to a memory address that is used by the hardware?

Some questions I have about this:

1. Why would that not cause a segmentation fault, given that you would be accessing an address that is out of the scope of your program?

2. How would you know the address to set the pointer to?
Yeap, there are such memory addresses. I've used them about ten years ago in DOS programming.
Look here for example http://www.techadvice.com/tech/M/mem-adr.htm
But anyway everything is finally transalting to machine dependant assembly commands. There is no other way to execute any code on a particular machine.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Okay, thanks everyone for your comments and insight about this issue.