[Coco] 6809 CC Reg Overflow bit
William Astle
lost at l-w.ca
Fri Nov 9 13:40:50 EST 2018
On 2018-11-08 9:54 p.m., James Jones wrote:
> The 6809 (or 6309) is the best 8/16 bit processor there ever was, but like
> other processors of the time, the register set is small and non-orthogonal.
> It might be tough to make a 6809 compiler play "as if", though if you could
> do it it would very much worthwhile--though to take full advantage of it
> you'd also want to bring in function prototypes--passing parameters is
> essentially assignment, and would thus provide more opportunity.
gcc6809 seems to do a pretty good job avoiding all the sign extension
business. It does so by the simple expedient of doing arithmetic on 8
bit values using 8 bit operations where possible. It's also pretty good
at optimizing useless stuff out of the final binary. At least if you
enable optimization, anyway.
I only mention that because it does show that a compiler can do better,
even with a 6809 target. Also, even if K&R demands that 8 bit operations
always be treated as 16 bit operations, even when the destination of the
result is known to be 8 bits, I would feel justified in treating that as
a bug in the specification and ignoring that provision (you're not going
to see a difference in the result if you do). That said, dealing with
different sizes of operation depending on context requires more semantic
analysis and, thus, more code complexity and more memory usage. As with
everything, it's a trade-off.
More information about the Coco
mailing list