Ricardo Seixas wrote: > > Here is a 16 bit BIN->BCD. > I don't know who's the original author but it works fine. > > ;----------------- Laser Cut Here ------------------------ > ;Converts Binary to BCD > ;Enter with 16 bit binary in LowByte/HighByte > ; > ;Exits with 5 digit packed BCD in R0,R1,R2 > > Bin_2_BCD bcf STATUS,C ; clear carry bit first > movlw 10h ; number of bits > movwf Count > clrf R0 > clrf R1 > clrf R2 > loop16 > rlf LowByte > rlf HighByte > rlf R2 > rlf R1 > rlf R0 > > decfsz Count,f > goto AdjustDEC > return > > AdjustDEC movlw R2 > movwf FSR > call AdjustBCD > > movlw R1 > movwf FSR > call AdjustBCD > > movlw R0 > movwf FSR > call AdjustBCD > > goto loop16 > ; > > AdjustBCD movlw 3 ; enter with FSR pointing > addwf 0,w ; to the BCD digit being shifted > movwf TEMP > btfsc TEMP,3 > movwf 0 > movlw 30h > addwf 0,w > movwf TEMP > btfsc TEMP,7 > movwf 0 > return > > ;----------------------------------- > > >Did someone do this routine with the assembly of PIC? > > > > Miguel. > > Falou!!! Amigo! Miguel.