Suma BCD

list p=16f877
include "p16f877.inc"

datoA equ 0x20;
datoB equ 0x30;
aux equ 0x21;
aux1 equ 0x22;
aux2 equ 0x23;
ac equ 0x24;
result equ 0x1A0;

org 0x00
goto inicio
org 0x05
inicio movf datoA,w ;
andlw b'00001111';
movwf aux2 ;
movf datoB,w ;
andlw b'00001111';
addwf aux2,f ;
movlw b'00001010';
subwf aux2,w ;
btfsc STATUS,Z ;
goto igual_1 ;
btfsc STATUS,C ;
goto acarreo_1 ;
sigue_1 movf datoA,w ;
andlw b'11110000';
movwf aux1 ;
swapf aux1,f ;
movf datoB,w ;
andlw b'11110000';
movwf aux ;
swapf aux,w ;
addwf aux1,f ;
movf ac,w ;
addwf aux1,f ;
movlw b'00001010';
subwf aux1,w ;
btfsc STATUS,Z ;
goto igual_2 ;
btfsc STATUS,C ;
goto acarreo_2 ;
bcf STATUS,C ;
clrf ac ;
sigue_2 movf aux2,w ;
bsf STATUS,RP0;
bsf STATUS,RP1;
movwf result ;
bcf STATUS,RP0;
bcf STATUS,RP1;
swapf aux1,w ;
bsf STATUS,RP0;
bsf STATUS,RP1;
addwf result ;
goto fin ;

igual_1 clrf aux2 ;
movlw .1 ;
movwf ac ;
goto sigue_1 ;

acarreo_1 movwf aux2 ;
movlw .1 ;
movwf ac ;
goto sigue_1 ;

igual_2 clrf aux1 ;
movlw .1 ;
movwf ac ;
goto sigue_2 ;

acarreo_2 movwf aux1 ;
movlw .1 ;
movwf ac ;
goto sigue_2 ;

fin NOP
end

No response to “Suma BCD”