[Coco] Mod10 Suggestions
wmikrut72 at gmail.com
Thu Feb 16 20:26:55 EST 2017
For years I have been an IBM programmer and have done well in that area --
for 30 years now.
I started with a CoCo2 back in 84/85 - and ML has always fascinated me --
yet eluded me to a degree.
With the advent of hardware (FPGAs) -- seems like we could do some pretty
So, I try to enter into the 8 Bit world that is CoCo and get down to some
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.
Attached is the MOD10 code.
I am hoping for constructive comments so I can learn, and move on to other
-------------- next part --------------
CCD RMB 16 ;Credit Card Number
RESULT RMB 1 ;Result for caluclations
STATUS RMB 1 ;#$00=Bad CCD #, #$FF=Good CCD#
START LEAX CCD,pcr ;Load the location of the number
STB #RESULT ;Clear the result field
LDA #16 ;16 Times through the loop
LDB A,X ;Load a With X
BITA #1 ;Test for Even/Odd Numbers
PROC.00 PSHS A ;We need to multiply the number by 2
PROC.01 SUBB #10 ;If over 10, Add the 2 numbers together.
INCB ;Since the biggest# can be 18, Sub 10 and Increment B once
PROC.02 ADDB RESULT ;Accumulate the result
CMPA #0 ;Are we done with all 16 numbers?
CHK.00 CMPB #10 ;This is a division trick. If the result is divisible by 10
BLO CHK.01 ;it's a good card number. Keep sbtracting 10 until the result
SUBB #10 ;is under 10. If so and B is zero, we have a good number.
BRA CHK.00 ;Else it's a bad number
CHK.01 CMPB #0
GOOD.00 LDA #$FF
SHOW.00 STA #STATUS
More information about the Coco