Regulus Berdin wrote: > I had checked your code, seems that there are > two errors on the result and may not work. Again I see no problem there. ;) 1. R=0 K=1 Cy=0 movfw Cy ;W=0 xorlw K ;W=1 iorwf Cy,f ;Cy=1 xorwf R,f ;R=1 andwf R,w ;W=1 xorwf Cy,f ;Cy=0 0 + 1 + 0 = 01b. Cy=0 R=1. Isn't it ? ;) 2. R=1 K=1 Cy=0 movfw Cy ;W=0 xorlw K ;W=1 iorwf Cy,f ;Cy=1 xorwf R,f ;R=0 andwf R,w ;W=0 xorwf Cy,f ;Cy=1 1 + 1 + 0 = 10b. Cy=1 R=0. The questions ? ;) Reggie there are no errors in this code. Please apply efforts to reduce it not to find an errors inside it. WBR Dmitry. > > movfw Cy ;carry cell > > xorlw K ;constant or second var > > iorwf Cy,f ;invertion mask > > xorwf R,f ;result > > andwf R,w ;pre-carry > > xorwf Cy,f lfinal true carry > > > > --> > > +--------+-------------+ > > | R K Cy | w Cy R w Cy | > > +--------+-------------+ > > | 0 0 0 | 0 0 0 0 0 | > > | 0 0 1 | 1 1 1 1 0 | > > | 0 1 0 | 1 1 1 1 0 |final Cy should be 1 because W=1 and Cy=0 > > | 0 1 1 | 0 1 0 0 1 | > > | 1 0 0 | 0 0 1 0 0 | > > | 1 0 1 | 1 1 0 0 1 | > > | 1 1 0 | 1 1 0 0 1 |also Cy should be 0 because W=0 and Cy=0 > > | 1 1 1 | 0 1 1 0 1 | > > +--------+-------------+