Thanks Chip and Regulus, that worked. Now another question. How did you know that MPLAB contained that macro? Is it possible to view the source for tant macro? Are there other macros of the same utility in that same location? Thank You Keith Causey -----Original Message----- From: Regulus Berdin To: PICLIST@MITVMA.MIT.EDU Date: Sunday, January 10, 1999 4:33 PM Subject: Re: Someone tell me if I'm blind >Hi, > >Your add routine may not work if the result of da2_l+da_1 has a carry >and da2_m is equal to 255 since it will become zero and the next >addition will be wrong. > >Use the standard routine: > >add32: > movf da2_l,w > addwf da1_l,f > movf da2_m,w > skpnc > incfsz da2_m,w > addwf da1_m,f > > movf da2_h,w > skpnc > incfsz da2_h,w > addwf da1_h,f > >regards, >Reggie > >Keith Causey wrote: >> >> Hello All, >> I am trying to debug a simple routine that adds two 32 bit numbers and I >> can't figure out why it keeps setting bits in the hi order bytes >> inappropriately. If you will take a look at this code and give some >> suggestions they would be much appreciated. The two arguments are in eight >> locations. Arg. 1 is, from least to most significant, in registers da1_l >> da1_m da1_h and da1_x. Arg. 2 is in da2_l da2_m da2_h and da2_x. On exit the >> sum is supposed to be in da1_l da1_m da1_h and da1_x. >> Here it is: >> movf da2_l, W >> addwf da1_l, SAME >> btfsc CARRY >> incf da2_m, SAME >> btfsc ZERO >> incf da2_h, SAME >> btfsc ZERO >> incf da2_x, SAME >> movf da2_m, W >> addwf da1_m, SAME >> btfsc CARRY >> incf da2_h, SAME >> btfsc ZERO >> incf da2_x, SAME >> movf da2_h, W >> addwf da1_h, SAME >> btfsc CARRY >> incf da2_x, SAME >> movf da2_x, W >> addwf da1_x, SAME >> If you look at this code >> Many Thanks >> Keith Causey >