Would you like signs with those chars?
Would you like signs with those chars?
Posted Oct 27, 2022 2:09 UTC (Thu) by gdt (subscriber, #6284)In reply to: Would you like signs with those chars? by SLi
Parent article: Would you like signs with those chars?
If the language insists on "char" being "unsigned char" then some processors will need to follow the register load with an AND instruction to clear the sign extension. If loading that register also sets register flags (eg, Negative) then you'll need to clear those register flags too. You could, of course, perhaps avoid this with careful compiler optimisations, but that's asking too much of the compilers of the era.
Well before the ANSI standards committee started work, the convention in C was to let these differences in processor implementations shine through, with an obligation on people writing code intended to be 'portable' between differing processors to deal with the results. Considering that C was a systems programming language, this wasn't an unreasonable choice.
