It was thus said that the Great ben via cctalk once
stated:
I don't know about the VAX,but my gripe is
the x86 and the 68000 don't
automaticaly promote smaller data types to larger ones. What little
programming I have done was in C never cared about that detail.
Now I can see way it is hard to generate good code in C when all the
CPU's are brain dead in that aspect.
char *foo, long bar;
... foobar = *foo + bar
is r1 = foo
r3 = * r1
r2 = bar
sex byte r3
sex word r3
r4 = r3 + r2
foobar = r3
what I want is
bar = * foo + bar
nice easy coding.
What CPUs did it correctly? And how did they handle signed
vs. unsigned
promotion?
unsigned char *ufoo;
unsigned long ubar;
ufoobar = *ufoo + ubar; // *ufoo will be promited to an unsigned long, added to ubar
and the result stored in ufoobar withouut any promotion or demotion (assuming ufoobar is
an unsigned long)
signed char *foo;
signed long bar;
foobar = *foo + bar; // *foo will be promoted to a long, added to bar and the result
stored in foobar without any promotion or demotion (assuming foobar is a long)
-spc