pointer -> long conversion - (nf)

Steven M. Haflich smh at mit-eddie.UUCP
Sat Jul 21 23:00:50 AEST 1984


>>Since when should pointers be sign-extended on a 68000, or any other
>>machine?  Unless someone comes up with a meaning for the notion of a
>>negative address, pointers should always be zero-extended.
>>-- Jim Balter, INTERACTIVE Systems (ima!jim)

Typical language execution environments on typical architectures (e.g.
C on a 68000) have two kinds of allocated memory.  The stack grows
automatically with things like procedure invocation.  The heap is
managed by explicit user calls (e.g. malloc/free).

On machines with huge virtual address spaces, it is quite reasonable to
keep addresses for the two separate.  Typically, virtual stack space
could grow downward from 0xffffffff while the heap grows upward from
0x0.  On a small dedicated-application system with limited physical
memory, and in which it is certain neither the stack and heap will grow
beyond 32K, it would be quite reasonable to keep pointers inside data
structures as 16-bit *signed* quantities.  In effect, one is modelling
memory as a range around zero (0xffff8000..0x00007fff) instead of the
usual notion of positive-number addressing (0x0..0x0000ffff).

I know it smells of crock.  You didn't say it had to be a *good* reason,
did you?

Steve Haflich, MIT



More information about the Comp.lang.c mailing list