Franchie wrote On 06/01/07 12:44,:
Surely the direction to your house is irrelevant at this point?
However, in the current context, we refer to an address in memory,
typically a *number* of bytes away from a given reference point.
In that sense, what is wrong with saying its a number??
Maybe you are right, though, and this is looking at computing too much
from a hardware standpoint, which is not ideal for high-level
programming.
In defence, the OP was asking about a micro-controller, which is
notoriously close to hardware ;-)
If anything, the micro-device world is *more* likely
to have addresses that are not simple numbers than is the
world of general-purpose computing. For example, the O.P.
has asked about two distinct kinds of memory with different
behaviors; memory on general-purpose machines is usually
homogeneous. Is there an a priori reason to believe that
these two kinds of memory should be integrated under one
comprehensive addressing scheme? (It appears that they
are so integrated on the O.P.'s machine, but I'm asking
about the logical necessity of such an integration.)
A few examples, some far-fetched but none impossible:
- ROM and RAM might exist in completely different
address spaces, accessed by different instruction
opcodes (perhaps with different timings to allow
for differently-performing memories). The address
0x4242 selects different data depending on whether
it's used in a LOADRAM or a LOADROM instruction.
- The large ROM region uses 32-bit addresses while
the tiny RAM uses 8-bit addresses. Some opcodes
can take advantage of the narrowness of a RAM
address to squeeze it into an instruction word
without using a separate pointer register.
- A system-wide "mode bit" determines whether addresses
in a certain range refer to ROM or to RAM; you can't
tell whether LOADFROM 0x4242 will fetch from ROM or
from RAM until you specify the mode bit's value.
(I once owned a Z80-based machine that used exactly
this scheme.)
Just interested... where does the 'pointer = memory address' idea not
work? Isn't that the very definition of 'pointer'?
There is obviously more to a C pointer than "address:"
double trouble = 42.0;
double *p = &trouble;
void *q = p;
assert (p == q); /* must succeed */
assert (*p == *q); /* doesn't even compile */
Clearly, p and q "point to the same address," yet just as
clearly they are not the same.