ON 20061027@3:33:34 PM at page: http://www.piclist.com/techref/microchip/math/radix/index.htm#39017.6482291667 James Newton[JMN-EFP-786] Says Code:
;some code snippets that someone might find useful...
;This routine will return the number of decimal
;hundreds from an 8-bit binary
;Input: w
;Output: w
;RAM:2
;Cycles: 12-24
GETHNDS movwf t1
clrf w2
gethnds_loop movlw .100
incf w2,f
subwf t1,f
btfsc STATUS,C
goto gethnds_loop
decf w2,w
return
;---
;This routine will return the number of decimal
;tens from an 8-bit binary
;Loop based, so it might take some time...
;It needs getones too
GETTENS movwf t1
clrf w2
gettens_loop movlw .10
incf w2,f
subwf t1,f
btfsc STATUS,C
goto gettens_loop
decf w2,w
goto getones
;---
;This routine will return the number of decimal
;ones from an 8-bit binary
GETONES movwf w2
movlw .10
deltens_loop subwf w2,f
btfsc STATUS,C
goto deltens_loop
addwf w2,w
return