Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do pointers allow Hardware access?

Tags:

c++

c

pointers

Pointers in C are very powerful and seem efficient. But how can using a pointer can give you access to hardware?

My idea of this would be setting a pointer's value equal to a hardware's associated object and than manipulating it through the pointer. But if you already have enough access to the hardware's objects and properties to use a pointer on it where does the pointer come into play? Perhaps im visualizing something wrong?

I'm running on windows 7.

A basic example along with an explanation of why the pointer is needed to manipulate that hardware property would be great.

like image 309
moonbeamer2234 Avatar asked Jun 20 '13 20:06

moonbeamer2234


1 Answers

The pointer holds a memory address. And not all of the memory addressing range points to RAM areas alone. Memory addresses have ranges and some ranges map to hardware registers. And by writing to these registers, we can access the hardware. Of course, this also depends on which operating system and which hardware. Here is an example.

like image 155
ruben2020 Avatar answered Sep 22 '22 02:09

ruben2020