Re: Declaring static pointers.



Franchie wrote On 06/01/07 12:44,:
On Jun 1, 5:55 pm, CBFalconer <cbfalco...@xxxxxxxxx> wrote:

You need to get rid of that idea. It may work some places, but not
all. For example, a pointer to my house might be:
"Go down this street two blocks, turn left, go one block,
turn right and it's the 3rd house on the left."
which you may note has a number, in fact several numbers,
directions, etc. It is not a number.


Surely the direction to your house is irrelevant at this point? :D

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.)

You need to get rid of that idea. It may work some places, but not all.


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.

--
Eric.Sosman@xxxxxxx
.



Relevant Pages

  • Re: Whip a duo-core PC into submission...?
    ... used are the Pointer type, which on Win32 contains the 32 bit ... the memory symmetrical in halves. ... 2GB process running on each core (ignoring OS and other ... overheads) in which case I naively assume that 4 GB of RAM ...
    (comp.dsp)
  • Re: XP/Max. Ram that it will recognize?
    ... Just make sure that the memory is properly recognized, go in the BIOS and take a look at the installed memory, in the BIOS the RAM should all show as being installed even if some of it is unavailable to the operating system. ... When all the numbers are used up the town finds out that it absolutely needs a water treatment plant and as all lots need numbers to be used they decide to go down to house number 3499 and rip the number off the house and stick it on the new water treatment plant and all of a sudden the folks who built a house on lot 3499 can no longer use it. ... I had 2, 1 gig modules, and 2 512 modules for a total of 3 gig. ...
    (microsoft.public.windowsxp.general)
  • Re: The Linear Address Space
    ... > The problem is that in a computer there is Hard Drive storage, RAM storage ... 36 bit pointer would allow you to access quite a lot of 180GB drives at ... > an abstraction or a virtualization of the true state of all of the ... Few key terms associated with virtual/paged memory: ...
    (comp.lang.asm.x86)
  • Re: Memory Limitations?
    ... I still don't see how system RAM and video RAM access are related. ... //pointer is a pointer type which is 32bits wide ... //video_display is the video card's memory which will display on ...
    (microsoft.public.windowsxp.customize)
  • Re: Declaring static pointers.
    ... a pointer to my house might be: ... has asked about two distinct kinds of memory with different ... ROM and RAM might exist in completely different ... The large ROM region uses 32-bit addresses while ...
    (comp.lang.c)

Loading