The logical NOT instruction is probably the simplist of all this family of instruction. It converts the destination address from its current state of ones and zeros into the exact opposite to zeros and ones. The format is :
NOT.size destination
Size can be byte, word or long. The instruction carries out a 'ones compliment' of the destination address. If you remember back to the discussion of 'Twos compliment' numbers earlier on in the series, you will remember that converting a posative number to negative involved flipping all the zeros and ones and then adding one to the result. The NOT instruction carries out the first part of flipping all the ones and zeros over.
If D0.W holds the value of $0001 then after a NOT.W D0, it will hold the value $FFFE. All the opriginal zeros have become ones and vice versa.
NOT must not be confused with the arithmetic NEG instruction which carries out a 'twos compliment' negation of a value. (D0.W in the above example would become $FFFF which is equivalent to NOT.W D0 followed by ADDQ.W #1,D0)
NOT affects the flags in the folowing way :
N is set if the result becomes negative - the most significat bit becomes a 1. Cleared otherwise.
Z is set if the result is zero, cleared otherwise.
V is always cleared - you cannot create an overflow by inverting the bits.
C is always cleard - there is no carry generated by flipping bits.
X is not affected.