Ahh, I see. I knew I was missing something simple, I'm now checking the MSB and all is well. Thanks Paul! Regards, Bob On 7/14/06, Paul James E. wrote: > > > Bob, > > Isn't it as simple as checking the MSB. That's the sign bit. > If it's a 1,it's negative. Then just add this to the other register. > You now have the result of x-y. You are subtracting by addition. > You don't have to subtract by subtracting. > > Jim > > > > > Sorry guys I fat fingered my previous message. Here's the rest of it. > > > > Guys, I have a value in W that's signed. Adding this value to a set of > > two variables is easy enough: > > addwf blahL,f > > clrf wreg > > addwfc blahH,f > > > > W contains a signed value. If the value of W is a negative, doing the > > following doesn't work (to subtract it instead of adding it.) > > > > addwf blahL,f > > clrf wreg > > bnc subtract > > addwfc blahH,f > >subtract > > subwfb, blahH,F > > > > I see why this is incorrect, but I'm not sure how you test for a 2's > > complement value in order to properly skip the subtraction if the value > > in W is not setting the carry or borrow flag when adding the lower > > byte. Can someone please steer me down the correct path? > > > > Regards, > > Bob > > > > > > > > > > > > On 7/14/06, Bob J. wrote: > >> > >> Guys, I have a value in W that's signed. Adding this value to a set > >> of two variables is easy enough: > >> > >> addwf blah,f > >> clrf wreg > >> addwfc > >> > > -- > > http://www.piclist.com PIC/SX FAQ & list archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist