> >Hi Byron, > >There is a generic multibyte addition routine that is on the Microchip >docs. I don't know who made it but works like a charm. > >;A = A + B > > movf B0,w > addwf A0,f ; add LSB > > movf B1,w ; W = next byte > skpnc ; skip next instr if there's a carry > incfsz B1,w ; inc W and skip next if B1 = 0xFF, C is still set > addwf A1,f ; add it except if C and B1 = 0xFF > > movf B2,w ; carry is propagated here if B1 was 0xFF > skpnc ; and C was set > incfsz B2,w ; or from the last addition > addwf A1,f > > movf B3,w > skpnc > incfsz B3,w > addwf A3,f I see. It basically does the same carry propogation I did in line instead of out of sequence. BAJ >>>>>>mult24x8: >>>>>> clrf prod0 ; Clear the product >>>>>> clrf prod1 >>>>>> clrf prod2 >>>>>> clrf prod3 >>>>>> clrf twofour3 ; Clear the top byte of the multiplicand >>>>>>return >>>>>> >>>>>>multloop: >>>>>> movf mulitiplier,W ; Check to see if eight bit is empty >>>>>> btfsc STATUS,Z ; Done if zero >>>>>> return >>>>>> bcf STATUS,C ; clear carry >>>>>> rrf mulitiplier,F ; Get the next bit >>>>>> btfss STATUS,C ; Add if carry is set >>>>>> goto multshift ; shift only if 0 >>>>>> movf twofour0,W ; Add the 32 bits of multiplicand to >>>>product >>>>>> addwf prod0,F ; each addwf sets the carry >>>>>> btfsc STATUS,C ; Don't increment if no carry >>>>>> incf prod1,F ; Add one to next byte if carry occured >>;Replace the line above with a call to the carry propogation routine. >> call carryprop1 >>>>>> movf twofour1,W ; >>>>>> addwf prod1,F ; >>>>>> btfsc STATUS,C ; Don't increment if no carry >>>>>> incf prod2,F ; Add one to next byte if carry occured >>;Replace the line above with a call to the carry propogation routine. >> call carryprop2 >>>>>> movf twofour2,W ; >>>>>> addwf prod2,F ; >>>>>> btfsc STATUS,C ; Don't increment if no carry >>>>>> incf prod3,F ; Add one to next byte if carry occured >>;Propogation unnecessary for the last byte. Leave as incf above. >>>>>> movf twofour3,W ; >>>>>> addwf prod3,F ; >>>>>> >>>>>>multshift: >>>>>> bcf STATUS,C ; clear carry >>>>>> rlf twofour0,F ; Shift the 24 bits one bit to the left >>>>>> rlf twofour1,F >>>>>> rlf twofour2,F >>>>>> rlf twofour3,F >>>>> >>>>> goto multloop ; need to add all partial products. >> >>carryprop1 incfsz prod1,F >> return >>carryprop2 incfsz prod2,F >> return >>carryprop3 incf prod3,F >> return >> >>>>> >>>>>> return ; Neither of these returns are required. >>>>>>return ; The routine will return when the multiplier is 0. >>>>> >>>>>> >>> >