Are you saying that the rlf Tens,f ;B1 = 2*(4A2+A1-92) = 8A2+2A1-184 is guarrenteed to generate a carry and that this is the +1 in the rlf Ones,f ;B0 = 2*(A3+A2+A1+4) = 2A3+2A2+2A1+9 and if so how can you be sure of the carry? Wow... I'm brain fried... I'll have to think about this more later. Thanks again. --- James Newton mailto:jamesnewton@geocities.com 1-619-652-0593 http://techref.massmind.org NEW! FINALLY A REAL NAME! Members can add private/public comments/pages ($0 TANSTAAFL web hosting) -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Scott Dattalo Sent: Friday, February 11, 2000 15:19 To: PICLIST@MITVMA.MIT.EDU Subject: Re: PIC Math FAQ page Importance: Low On Fri, 11 Feb 2000, James Newton wrote: > Doh! adding A2 twice does not multiply by 2! Thanks for spotting that one. > > >-92 = 0xa4 > > and 0xa4 << 1 is 0x48 > yes, but 0x48 or (72 + x) mod 256 is (x-184) mod 256 or in other words, > adding 72 and wrapping around 256 is the same as subtracting 184. I think > I'm right on that one. True but, there's also that carry bit. A two's complement can be written in terms of a one's complement: two's complement of x = 1 + one's complement of x. So, taking this snippet from your web page: > >>> rlf Tens,f ;B1 = 2*(4A2+A1-92) = 8A2+2A1-184 > >>> rlf Ones,f ;B0 = 2*(A3+A2+A1+4) = 2A3+2A2+2A1+8 > comf Ones,f ;B0 = -2A3-2A2-2A1-8 > rlf Ones,f ;B0 = 2*(-2A3-2A2-2A1-8) = -4A3-4A2-4A1-16 rlf Tens,f ;B1 = 2*(4A2+A1-92) = 8A2+2A1-184 (I'll leave this) rlf Ones,f ;B0 = 2*(A3+A2+A1+4) = 2A3+2A2+2A1+9 comf Ones,f ;B0 = ~(2A3+2A2+2A1+9) = -2A3-2A2-2A1-8 rlf Ones,f ;B0 = 2*(-2A3-2A2-2A1-8) = -4A3-4A2-4A1-16 The comf's comment is still the same... So now that I think about it, Payson new what he was doing (ah, should I have ever doubted...) Scott