> A byte-optimized assembler implementation of the subtraction method could
> look like this:
>
In the conversion from BYTE to ascii scope, you need to extract the 3
digits of that byte. It may be achieved like this:
(assuming the value is in W)
clrf HUNDREDS ; Clear hunds
clrf TENS ; Clear tens
addlw h'38' ; Try subtracting 200
rlf HUNDREDS, F ; Pick up the result from the carry
btfss HUNDREDS, 0 ; If it was less than 200
addlw h'C8' ; We guessed wrong, so add 200 back
addlw h'9C' ; Try subtracting 100
rlf HUNDREDS, F ; Pick up the result from the carry
btfss HUNDREDS, 0 ; If it was less than 100
addlw h'64' ; We guessed wrong, so add 100 back
addlw h'B0' ; Try subtracting 80
rlf TENS, F ; Pick up the result from the carry
btfss TENS, 0 ; If it was less than 80
addlw h'50' ; We guessed wrong, so add 80 back
addlw h'D8' ; Try subtracting 40
rlf TENS, F ; Pick up the result from the carry
btfss TENS, 0 ; If it was less than 40
addlw h'28' ; We guessed wrong, so add 40 back
addlw h'EC' ; Try subtracting 20
rlf TENS, F ; Pick up the result from the carry
btfss TENS, 0 ; If it was less than 20
addlw h'14' ; We guessed wrong, so add 20 back
addlw h'F6' ; Try subtracting 10
rlf TENS, F ; Pick up the result from the carry
btfss TENS, 0 ; If it was less than 10
addlw h'0A' ; We guessed wrong, so add 10 back
movwf ONES ; Save ONES
27 instructions; this code was made from an original code from Scott
Dattalo.
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.