2s Complement
Mike G
Posts: 2,702
I’m sure there is a quicker way to calculate 2’s complement than my 3 lines of Propeller assembly code?
neg chkSum,t1 sub chkSum,#1 and chkSum,#$FF
Comments
However it seems you want the least 8 bits only, then it would be
You will not need the AND if the original bits 8..31 are already cleared.
Your code does a 1's complement. For 2's complement, you need to add a ADD chkSum,#1 between the XOR and AND. But this would be quicker:
-Phil
-Phil