> On Aug 15, 2024, at 4:41 PM, Sean Conner via cctalk <cctalk@classiccmp.org> 
> wrote:
> 
> 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;
> 
>       signed char *foo;
>       signed long  bar;
> 
>       foobar = *foo + bar;
> 
>  -spc

Obviously, "correctly" is in the eye of the beholder.  You can do size 
extension, signed or unsigned, on any computer.  How complicated it is depends 
on the machine.

For example, on VAX there are instructions for signed as well as unsigned 
promotion (CVTxy and MOVZxy respectively).  On PDP11, MOVB into a register does 
sign extension; unsigned promotion requires two instructions but that's no big 
deal.  And of course, promotion to bigger types requires multiple instructions 
either way since you're now dealing with multiple registers.

Unsigned promotion on a CDC 6600 is one instruction; signed requires three.

        paul

Reply via email to