Hi Luciano,

"From your code I see that the 5 decimal digits (input data)
are stored in a 5 bytes array. One byte per digit, so there is
no binary-coded decimal. (No BCD)."

That's why I do this:

DIGIT4 = DATAIN[0] - BCD48
DIGIT3 = DATAIN[1] - BCD48
DIGIT2 = DATAIN[2] - BCD48
DIGIT1 = DATAIN[3] - BCD48
DIGIT0 = DATAIN[4] - BCD48

Using 0 as an example, I convert each digit individually from an ASCII value (0011 0000), to a binary value (0000 0000), by subtracting 48 (0011 0000). I am left with digits which are compatible with BCD format; bits in the lower nibble representing 0 to 9.

The Assembler sub-routine takes care of doing all the math, all I had to do was prepare the digits. I tested the routine with numbers like 56,789 and it worked flawlessly, the 2nd time (11011101 11010101). LOL I had some stuff backwards and used the wrong variable as input. But that's a chair-keyboard problem, the sub-routine is good.

I'm curious though, can you tell me how many cycles your code converts into once it's all said and done? The author of the sub-routine boasts 33 cycles, I wonder if that is truly remarkable, or if he's only 2 or 3 cycles less than your solution.

Robert