Ullrich von Bassewitz wrote: > Hi! > > On Fri, Oct 23, 2009 at 11:03:40AM +0300, Karri Kaksonen wrote: > >> Anyway all my code is written this way. I obviously need to add >> --signed-chars to all my Makefiles. >> > > I would suggest to check the code instead. Any compiler is free to choose > either, so code that makes assumptions about the signedness of chars is highly > non-portable. > > cc65 uses unsigned chars, because operations with signed data generates much > more code and is slower. For chars, the problems is what the standard calls > "integer promotion". In short, this means that all arithmetic operations > operate on ints, even if all operands are chars. So the compiler needs to do > sign extension on operands. Which - in case of unsigned chars - means just > loading 0 for the high byte. But for signed chars, the sign of the char has to > be tested and either 0x00 or 0xFF needs to be loaded for the high byte. > > Regards > > > Uz > Ok. My next project is an Elite-inspired space shooter that has heavy use of 16 bit matrix operations (rotate, scale). The plan is to use the math hardware in Suzy so that I can use the CPU for other things simultaneously. The Suzy has some combined hw functions like 24 bit accumulator with 16 bit operands "a += b * c" in a single operation. Many intermediate results are 24 bit so I may end up in needing signed chars here and there. But this time I declare every "signed char" properly. -- Regards, Karri ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Fri Oct 23 12:15:22 2009
This archive was generated by hypermail 2.1.8 : 2009-10-23 12:15:23 CEST