from Andy Warren
If [...] your original number is in a register, you can do it with this bit of code:
COMF REG ;REG = two's-complement of REG. INCF REG ;
or this one:
COMF REG,W ;W = two's-complement of REG ADDLW 1 ;(REG is unchanged).
If the original number is in W, the easiest way is:
SUBLW 0 ;W = two's-complement of W.
Clyde Smith-Stubbs [clyde at htsoft.com] of HI-TECH Software says
[These snippits do not handle the problem: REG = 0x80] because there is no correct result in this case. The value 0x80 interpreted as 2's complement is legal, and equal to -128. The negative of this, 128, is NOT representable as an 8 bit 2's complement number.