[Coco] 6809 CC Reg Overflow bit

James Jones jejones3141 at gmail.com
Thu Nov 8 23:54:16 EST 2018


On Tue, Nov 6, 2018 at 5:24 PM Gene Heskett <gheskett at shentel.net> wrote:

> I think so, v is set (I think) if the result is >127, for 2's complement
> math. This also explains the need for the SEX, or sign extend
> instruction, something the C compiler goes crazy with.
>

That is because the compiler dutifully follows the C specification of what
are now called "the usual arithmetic promotions" (which differ between K&R
1st edition and ANSI/ISO C; the latter does "value preserving" widening,
pre-ANSI does "unsigned preserving" widening). Microware's 68xxx compiler
and Ultra C take advantage of the ANSI/ISO "as if" rule, which essentially
says you can generate whatever the [expletive] code you want, just as long
as you get the same result as you would if you followed the letter of the
spec.

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.


More information about the Coco mailing list