; File name : bin_bcd.asm ; Date : 23/11/2000 ; File Version : 01 ; Author : Ing. Francisco Armenta ; Company : Briones Sistemas de Pesaje S.A. de C.V. ; Files Required : P16F873.INC ; MATH.H ; Notes: Conversion binaria a BCD list p=16f873 ; Definicion de Procesador #include ; Definicion de Registros del Procesador #include ; Definicion de Variables para funciones Matematicas ; Definicion de Variables locales TEMPORALES UDATA_OVR ibin RES 1 ; Contador MATH_LIB CODE bin_bcd GLOBAL bin_bcd movlw .24 movwf ibin ; Inicializa contador de bits clrf fm_outl ; dato BCD = 0 clrf fm_outh clrf fm_outu goto inc_bcd ; Ve a incrementar BCD badj movlw 0x33 ; BCD = BCD+333333H addwf fm_outl,f addwf fm_outh,f addwf fm_outu,f movlw 0x03 btfss fm_outl,3 ; BCD(0:3)>=8? subwf fm_outl,f ; else: BCD(LSB) = BCD(LSB)-3 btfss fm_outh,3 ; then: BCD(HSB)>=8? subwf fm_outh,f ; else: BCD(HSB) = BCD(HSB)-3 btfss fm_outu,3 ; then: BCD(USB)>=8? subwf fm_outu,f ; else: BCD(USB) = BCD(USB)-3 movlw 0x30 ; then: btfss fm_outl,7 ; BCD(4:7)>=8? subwf fm_outl,f ; else: BCD(LSB) = BCD(LSB)-30 btfss fm_outh,7 ; then:BCD(8:15)>=8? subwf fm_outh,f ; else: BCD(HSB) = BCD(HSB)-30 btfss fm_outu,7 ; then: BCD(20:23)>=8? subwf fm_outu,f ; else: BCD(USB) = BCD(USB)-30 inc_bcd ; then: rlf fm_in1l,f ; ls bit de BCD = ms bit de bin rlf fm_in1h,f rlf fm_in1u,f rlf fm_outl,f rlf fm_outh,f rlf fm_outu,f decfsz ibin,f ; contador = contador -1 = 0 ? goto badj ; else: repite el ciclo retlw 0 ; then: fin END ; Fin de Codigo