;------------------------------------------------------------------------------- ;-------------------------- Binary to Decimal Routine ------------------------- ;------------------------------------------------------------------------------- BCD clrf digit1, 0 clrf digit2, 0 clrf digit3, 0 clrf digit4, 0 clrf digit5, 0 clrf digit6, 0 clrf digit7, 0 clrf digit8, 0 movlw d'24' ;24 bits to do movwf bcdtmp1, 0 bcf STATUS, C bitlp rlcf count0, f, 0 ;Shift msb into carry rlcf count1, f, 0 rlcf count2, f, 0 movlw LOW digit1 movwf FSR1L, 1 ;Pointer to digits movlw HIGH digit1 movwf FSR1H, 1 ;Pointer to digits movlw d'8' ;8 digits to do movwf bcdtmp2, 0 adjlp rlcf INDF1, f, 1 ;Shift digit 1 bit left movlw d'10' subwf INDF1, w, 1 ;Check and adjust for decimal overflow btfsc STATUS, C ;Postinc affects both fsrl and fsrh movwf POSTINC1, 1 btfss STATUS, C movf POSTINC1, w, 1 ;This is just to postinc, decfsz bcdtmp2, f, 0 goto adjlp decfsz bcdtmp1, f, 0 ;Next bit goto bitlp return