Would you like signs with those chars?
Would you like signs with those chars?
Posted Oct 25, 2022 9:51 UTC (Tue) by pbonzini (subscriber, #60935)In reply to: Would you like signs with those chars? by eru
Parent article: Would you like signs with those chars?
I suspect most x86 developers have never heard of Lattice C. :)
> The original 16-bit 8086 did not have the sign-extending 8-bit load as a single instruction, so it was more efficient to treat char as unsigned.
"mov al, [x] + cbw" (sign extending) is even one byte shorter than "xor ax, ax + mov al, [x]", so there is no particular x86-specific reason to pick unsigned over signed. Unsigned chars are simply more intuitive; signed-by-default chars are a relic of K&R C not having the signed keyword at all.
