Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pointer to absolute memory address

12 views
Skip to first unread message

j...@statoil.no

unread,
Jan 30, 1998, 3:00:00 AM1/30/98
to

How do I declare and initialize a pointer to an absolute memory address
in C?
What I want do do is access all my 32K of memory byte by byte starting
at adress 0x0000.
I'm sure it's simple, but my compler keeps giving me error messager when
I try to do it.

Regards, Gunnar Knutson

Richard Stamp

unread,
Jan 30, 1998, 3:00:00 AM1/30/98
to

C allows you to cast an integer to a pointer type, like this:

*my_int_ptr = (int *) 0xF00BA;

(and similarly, of course, for other pointer types). The result of
this is implementation defined so may vary from compiler to compiler.
However, one common implementation is that the result is a pointer
to whatever object is located at that address.

Whether or not this gives you the result you wanted depends entirely
on your platform, operating system and compiler. For example, with
my UNIX-like OS there's just no way for an ordinary program to
access the whole of physical memory. For more information you'll be
best off asking in a newsgroup targeted at your particular system.

Cheers,
Richard
--
Richard Stamp
Churchill College, Cambridge

Ulric Eriksson

unread,
Jan 30, 1998, 3:00:00 AM1/30/98
to

In article <34D1E3...@hotmail.com>, <j...@statoil.no> wrote:
~~~~~~~~~~
Mhm...

>How do I declare and initialize a pointer to an absolute memory address
>in C?
>What I want do do is access all my 32K of memory byte by byte starting

~~~~~~~~~~~~~~~~~~~~

Programming a gas pump? ;-)

Ulric
--
Another opinion presented as fact.

0 new messages