[Coco] Mod10 Suggestions

Brett Gordon beretta42 at gmail.com
Thu Feb 16 22:27:29 EST 2017


+1 on Robert's comments.

In addition: try to arrange your loop so that you can dec A reg, just
before the bne for the grand loop.  Dec a has the side effect of setting
Z.. then no reason for cmpa#0 or tsta.

   Lda  #15
loop:
     ... do some stuff (body)
   Dec a   (dec and test for zero)
   Bne loop

If you use lslb rather than mul then  you dont have to go through the
hassle of pushing/pulling A either.

When can we expect a CoCo based card credit card reader?  ;)  (all you need
is a old tape deck, a coco, and the cassette cable... hack! hack!)

brett
On Feb 16, 2017 10:06 PM, "William Mikrut" <wmikrut72 at gmail.com> wrote:

> 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
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list