[Coco] Mod10 Suggestions
William Mikrut
wmikrut72 at gmail.com
Fri Feb 17 23:44:19 EST 2017
I am definitely going to try it later.
I won't be near my console until tomorrow... but believe me, I am dying to
code/try it!
On Feb 17, 2017 10:15 PM, "Brett Gordon" <beretta42 at gmail.com> wrote:
> Ok.. this actually works on a calculator on my bank card. A zero is
> prepended so it shifts the odd/even digits around, and we do need to add
> digits of shifted bytes ;(
>
> Ldy #num y points to beg of number
> Ldx #0 x is an 16 bit accumulator
> loop:
> ldd ,y++ get next word
> abx accum even digit
> lsla shift odd digit
> cmpa #10 add digits if > 9
> blo skip
> suba #9
> skip:
> tfr a,b no aax ;(
> abx accum odd byte
> cmpy #num+16
> bne loop
> * find mod
> tfr x,d full bit tests only in D :(
> again
> subd #10 subtract 10 until we go neg
> bpl again
> addd #10 went too far! Add back last 10
> * result in D (0= good cksum)
> beq beep like at the supermarket
> bra boop bad swipe
>
> I get ~34 bytes of code + 16 data + 0 stack. Although the pcr addressing
> would add a few bytes of code and data.
>
> cheers
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
More information about the Coco
mailing list