Malone wrote: >Does anyone know how to convert 32 bits binary to BCD format? There probably faster routines but this should do the job. ;Binary - BCD 32 bits ;Input in buff_4|buff_3|buff_2|buff_1, ; ;Converts to *packed* bcd in temp_a, temp_b, temp_c, temp_d and temp_e ;with the MSD temp_a. ;Handles full range: ff ff ff ff -> 4,294,967,296 ;Also uses temp_f and count. ;2940 cycles including call and return. bin2bcd: bcf STATUS, C movlw 32 movwf count clrf temp_a clrf temp_b clrf temp_c clrf temp_d clrf temp_e bin2bcd_loop: rlf buff_1, f rlf buff_2, f rlf buff_3, f rlf buff_4, f rlf temp_e, f rlf temp_d, f rlf temp_c, f rlf temp_b, f rlf temp_a, f decfsz count, f goto adj_dec goto done adj_dec: movlw temp_e movwf FSR call adj_bcd movlw temp_d movwf FSR call adj_bcd movlw temp_c movwf FSR call adj_bcd movlw temp_b movwf FSR call adj_bcd movlw temp_a movwf FSR call adj_bcd goto bin2bcd_loop adj_bcd: movlw h'3' addwf INDF, w movwf temp_f btfsc temp_f, 3 movwf INDF movlw h'30' addwf INDF, w movwf temp_f btfsc temp_f, 7 movwf INDF return done: return -- Bob Fehrenbach Wauwatosa, WI bfehrenb@execpc.com