Full Version : Decimal Math Routines (PIC ASM)
avr >>MATH ROUTINES >>Decimal Math Routines (PIC ASM)


Admin3- 04-18-2006
CODE

;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



Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.