[Coco] Mod10 Suggestions
William Astle
lost at l-w.ca
Fri Feb 17 18:04:21 EST 2017
On 2017-02-17 03:50 PM, William Mikrut wrote:
> The reason being I am actually reading the number from right to left.
> So I need that A,x (16,X) then (15,X) and so on offset to process the
> numbers.
>
> I don't know of another way to maintain that index while counting down.
Actually, I did make an error in my description. It should be BPL to
branch when not negative so it keeps looping until DECA results in 255
(or -1). That's what I get for being distracted when I wrote the message.
However, if you do exactly what I wrote (modulo the BMI/BPL error), you
will have *exactly* the same result. That's because you're doing the
DECA at the start of the loop so it doesn't change the conditions inside
the loop if you start with A at 15 and do the decrementing at the end of
the loop or start with A at 16 and do the decrementing at the start of
the loop. Either way, A is still in the range of 0...15 during the loop.
Basically, you have "LDA #15" at the start. Remove the DECA at
"LOOP.00". Replace CMPA #0 (or TSTA) with "DECA" and change the "BNE
LOOP.00" to "BPL LOOP.00". Unless I'm miscalculating that will save you
one additional byte.
More information about the Coco
mailing list