??? 12/05/05 10:29 Read: times |
#104692 - another approach Responding to: ???'s previous message |
instead separate collecting digits and conversion, many code space can be saved, if every digit was converted immediately as it arrived.
Then you need only a small routine, which multiply the old value by 10 and add the new digit: ;********************** Multiplication * 10 for decimal input ********** ; ;Input: R0 point to X (LSB) ; ACC = new digit ;Output: X = X * 10 + ACC amula10: mov r2, #4 ;4 byte value _amu1: mov r3, a ;digit to add mov a, @r0 mov b, #10 mul ab ;* 10 add a, r3 ;add digit or carry mov @r0, a clr a addc a, b ;add carry inc r0 ;next byte djnz r2, _amu1 ret Furthermore the same routine can handle smaller or bigger values, simple by changing the loop counter R2 accordingly. Peter |