On Sun, Aug 23, 2009 at 08:27:25PM +0200, Johan Kotlinski wrote: > It seems wrong to me, that it checks the return from cbm_save using x. > Isn't the return value in a? One of the basic rules of expression evaluation in C is, that all characters are promoted to ints. This means that the above is correct code. So with 8-bit chars unsigned char C = 0x01; unsigned char S = 8; int I = C << S; gives 0x100, and not some undefined value (as it would be if the shift operation would act on characters). Another rule says that the compiler may do what it wants as long as the compiled code behaves as if all rules of the standard have been followed. This rule is called the "as if" rule. This means that the compiler is free to operate on characters (or whatever) as long this does not change the result. In the given case, the compiler could just check the A register, but it's not required to. Please note that this does also mean that assembler routines that return characters must actually return an integer value! Regards Uz -- Ullrich von Bassewitz uz@musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Sun Aug 23 23:20:53 2009
This archive was generated by hypermail 2.1.8 : 2009-08-23 23:20:55 CEST