[stella] Question about Circus Atari and BCD addition

stella at casperkitty.com stella at casperkitty.com
Wed Jun 20 17:54:20 CDT 2007


BCD math is performed by doing 'ordinary' math, observing the status of the
carries out of bits 3 and 7, and then adjusting the result.  When
performing addition, if there was a carry out of bit 3, or if the lower
nybble is $A or greater, the 6502 will add $06.  If there was a carry out
of bit 7, or if the upper nybble was $A or greater, or if the upper nybble
was $09 and the lower nybble was $0A or greater or had a carry, then add
$60.

This will generally yield nice results even with some out-of-bounds values,
but other out-of-bounds inputs will yield outputs that are not
arithmetically correct.  For example, $0F+$0F should yield $31, but there's
no way anything that fits entirely in the lower nybbles can yield a value
over $1F.

--------------------------------------------------------------------
mail2web.com - Microsoft® Exchange solutions from a leading provider -
http://link.mail2web.com/Business/Exchange






More information about the Stella mailing list