(12C) Luhn algorithm
|
04-24-2018, 08:27 PM
Post: #6
|
|||
|
|||
RE: (12C) Luhn algorithm
(04-24-2018 06:35 PM)Dieter Wrote: First of all: you can save two steps if you have the "1" in line 16 followed by a STO+1. This way the counter is incremented en passant and you can delete the three steps near the end that do it now.Yes!! (04-24-2018 06:35 PM)Dieter Wrote: But... sometimes even good ideas don't work. All this would be fine, even with four steps saved, IF the 12C had an X<Y? test as originally shown in your listing (I now see you corrected this). But in fact the 12C features an X≤Y? test. This way the digit 9 will not get processed correctly. Since 9 ≤ 9 the test is true, so X=0? is also tested, which is false, so the CLX is not executed and the result is zero (9 – 9). So this method is not an option here.Whoo, lack of test on my side! There is another way to avoid the >9 test: add the 2 numbers, even if there is a leading zero. This can be done with: Code:
So I decided to store 10 in R2, to spare 2 lines. New code is: Code:
This time I think it has been tested! Same usage, but now R2 is used. Result in R0, counter in R1. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(12C) Luhn algorithm - pinkman - 04-18-2018, 06:29 PM
RE: (12C) Luhn algorithm - Dieter - 04-23-2018, 08:19 AM
RE: (12C) Luhn algorithm - pinkman - 04-24-2018, 08:00 AM
RE: (12C) Luhn algorithm - Dieter - 04-24-2018, 06:35 PM
RE: (12C) Luhn algorithm - Dieter - 04-24-2018, 07:40 PM
RE: (12C) Luhn algorithm - pinkman - 04-24-2018 08:27 PM
RE: (12C) Luhn algorithm - Dieter - 04-25-2018, 07:22 AM
RE: (12C) Luhn algorithm - pinkman - 04-25-2018, 02:52 PM
|
User(s) browsing this thread: 1 Guest(s)