[Coco] Mod10 Suggestions

Mark McDougall msmcdoug at iinet.net.au
Thu Feb 16 21:19:21 EST 2017


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>


More information about the Coco mailing list