pointer sizes, was: Re: What does char **ch mean?

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Thu May 16 13:50:20 AEST 1991


In article <wolfram.674309645 at akela>, wolfram at akela.informatik.rwth-aachen.de (Wolfram Roesler) writes:
> I advised somebody something similar to that, telling him (like I learned
> from the FAQ) that weird machines have weird pointers, that (char*)0 and
> 0L might have different binary representations and the like. His response
> to this was:
> 	"I claim there are no machines like this"

When I had access to a Prime P400, 0L was 32 bits, but char* pointers
were 48 bits.  Given that pointers contained 2 "ring" bits with three
possible rings (kernel, supervisor, user), there were three distinct
bit patterns that identified (segment 0, word 0), and all of them had
the same effect in user-mode code.  I once had access to a machine where
0L was 64 bits but char* was 32 bits.  If I remember correctly, function
pointers were longer than data pointers on 68000-based Apollos.

On a 386, (far char *)0 could quite plausibly be 48 bits (segment:16,
byte within segment:32) as that's what the hardware is prepared to handle.
I imagine OS/2 would find this useful.  0L would still be 32 bits.

If anyone ever figured out how to put C on a B6700 (what do they call
them now, A series?) pointers have tag 5 and integers have tag 0, so
the binary representation would certainly be different.

Take a look at the address encoding on System 370/XA.
In older System/370s, there were 256 binary encodings of any address
(24-bit address in 32-bit words, top 8 bits ignored) so a compiler
could quite legitimately have implemented (char*0) as 0xFF000000.
XA machines have 31-bit addresses.  (With the _really_ big machines,
it gets complicated.)

On DEC-10s an address had (indirect: 1, index register: 4,
field width: 6, field offset: 6, word number: 18) or something like
that.  The code for "7-bit character at address 0", which I take to
be the obvious reading of (char *)0, would have to be something like
0000700000000.  (If you want 9-bit bytes, to make it more like a
32-bit machine, use 0001100000000.)  This is not the same as 0L.
0L _would_ be a useful code for (int *)0.

These are just some of the _less_ exotic machines...
-- 
There is no such thing as a balanced ecology; ecosystems are chaotic.



More information about the Comp.lang.c mailing list