sizeof

Guy Harris guy at rlgvax.UUCP
Tue Feb 5 14:52:36 AEST 1985


> The 68000 only uses 24 bits for addressing, but uses them either
> 1) as a 32 bit item in the instruxion stream, & 2) in a 32 bit register.

10 points for originality, but that's NOT why I said a Motorola 68000-based
machine may have sizeof (int) != sizeof (int *).  The reason why they
may (and do - our current ones do; it's a pain in the *ss, and I prefer
32-bit "int"s, but what we did was not illegal, immoral, or fattening)
be different is:
> > 
> > Because it doesn't say anywhere that you can't.  Because you may not want
> > to pay the penalty for 32-bit arithmetic.
> 
> If you have a machine with an address space > 64k, you probably have
> 32 bit registers.

Who said anything about the register size?  The 68000 has 32-bit registers;
anybody who claims there's no speed penalty for 32-bit arithmetic on
the 68000 has been smoking those funny cigarettes too long.  32-bit by
32-bit divides are NOT cheap on the 68000 (32-bit by 16-bit ones aren't
cheap either, but they're a lot cheaper than 32-bit by 32-bit ones).

> > On this point, I agree.  16-bit "int"s make techniques like using "malloc"
> > and "realloc" to grow a large table (used by such obscure programs as "nm")
> > lose big.
> 
> I just read a news item from yourself which stated:
> 	"THERE IS NO SUCH THING AS A GENERIC NULL POINTER"
> Presumably because of different length pointers. Which way do you want it?

1) It's not just because of different length pointers; the representation
could be different.

2) I prefer "int"s to be able to hold the size, in bytes, of an object
of approximately the same size as the address space.  I don't give a
tinker's damn whether different kinds of pointers are congruent or not.
One can imagine a machine where "int"s are big enough to hold the size
of the aforementioned object in bytes, but where "char *" and "int *" are
different sizes.  An example would be a word-addressed machine with a 64KW
address space.  Choose sizeof (int) == 32 bits (remember, sizes are in bytes),
sizeof (int *) == 16 bits (large enough to hold the largest possible pointer
to "int"), sizeof (char *) == 32 bits (at least 17 bits are necessary).
Possibly a dumb machine, but it points out that the question
"Which way do (I) want it" is meaningless, given that your two choices
are not mutually exclusive.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.lang.c mailing list