machines with oddball char * formats

William E. Westfield billw at navajo.STANFORD.EDU
Tue Nov 18 06:29:27 AEST 1986


Yes, the DEC-20 and DEC-10 computers (the same processor, actually)
are word addressable machines, and pointers to bytes smaller than
36 bits have a special format (containing the position within a word,
the byte size, and the addres of the word).  There are several
successfull C compilers for the 20 better than the version of PCC
written for it at MIT.  There is one from New Mexico, and one from
Stanford.  A variety of bytes sizes are used for Chars are variously
7, 8 or 9 bits (7 allows efficient text packing 5 chars/word.  8 is
what most people writing "portable" code assume a char has.  9 allows
structs to be copied using say, cpystr, since it hits all the bits.)

Personally, I feel that a mjor weakness of "C" as a "portable"
language is its assumtion of byte addressability.

here's an except for the stanford tops20 C compiler (KCC) doc:

------
All pointers are a word long.  Char pointers (and someday short
pointers) are either local or one word global byte pointers to the
byte itself (LDB rather than ILDB pointers).  Pointers to word and
multi-word quantities are simply (global) machine addresses.

<Coercions>

(char *) of a word pointer (pointer to int, float, struct etc)
produces a byte pointer that points to the leftmost 9-bit byte that
would have occupied the word pointed to by the int pointer.  The
exception to this is that (char *) (int *) NULL remains zero.

(int *) of a char pointer produces an address that points to the word
that the char in which the char pointer is pointed to occupies.
Converting a char pointer into an int pointer is slightly slower than
the reverse transformation.  Again, coercing zero doesn't change it.
-----

BillW



More information about the Comp.lang.c mailing list