[Coco] Mod10 Suggestions

William Mikrut wmikrut72 at gmail.com
Thu Feb 16 22:06:30 EST 2017


The only reason I am using lda a,x is I am actually reading the number
backwards (from right to left)... not that I have to.

For that MUL I should have used an ASLB -- 2x1 is still 2!

Why not sub 9... right!  I get too caught up in the technique instead of
the practical.

I was using A for a loop counter because I didn't want to keep loading a
var with a value.
however, I'll give it a try.

Thank you for the suggestions!!




On Feb 16, 2017 8:20 PM, "Mark McDougall" <msmcdoug at iinet.net.au> wrote:

On 17/02/2017 12:26 PM, William Mikrut wrote:

Following is a MOD10 program I have used for years in IBM programs.
> I have translated it the best I can...I am sure it is not the most
> efficient... and I have much to learn.
>

I can't go through it now but a couple of things jump out at me
immediately...

* Rather than using LDB A,X to get the next digit, simply increment X each
time through the loop, using auto-increment.

* Multiply by 2 is a left shift. Because your digits are 0-9, you'll never
get overflow.

* Why sub 10, then add 1? Why not sub 9?

* I'd probably store the loop counter on the direct page myself.

* Count from 15 to 0 (-1) to eliminate CMPA #0 (which can be replaced with
TSTA in this case)

* Should be STB RESULT (no hash)

I'm sure Simon can get this down to 4 lines (with music)! ;)

Regards,

-- 
Mark McDougall
<http://retroports.blogspot.com.au>

-- 
Coco mailing list
Coco at maltedmedia.com
https://pairlist5.pair.net/mailman/listinfo/coco


More information about the Coco mailing list