At 10:06 AM 3/7/00 +0200, Werner Soekoe wrote: >Hi > >I'm looking for the way to calculate what the Two's >Complement of a value will be. Can anyone help me? >For instance: > >8-bit value: >01101110 >10010001 (Inverted) > >But this is not two's complement yet!? What Next? > >Can somebody maybe also solve this one: >16-Bit value: >01011100 11110110 >10100011 00001001 (Inverted) What you just did is called one's compliment. To turn the result into two'scompliment, just add 1 (and propagate any carries between bytes) Here are 2 different routines, pulled from working code ;2 byte negate. Invert all bytes, add 1. Extensable to 3 or more bytes. comf AD3M,F comf AD3H,F incf AD3M,F skpnz incf AD3H,F ;3 byte negate (extensable) comf AD3L,F comf AD3M,F comf AD3H,F movlw .1 addwf AD3L,F skpnc addwf AD3M,F skpnc addwf AD3H,F hope this helps. dwayne Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax Celebrating 16 years of Engineering Innovation (1984 - 2000) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Do NOT send unsolicited commercial email to this email address. This message neither grants consent to receive unsolicited commercial email nor is intended to solicit commercial email.