neg
Negate
Replaces the destination operand with zero minus its value, at the given size.
Sizes .b .w .l, .w by default
Used in
- The screen, keyboard and mouse through trapsM68K assembly
- The bigger of two numbersM68K assembly
- A bouncing ballM68K assembly
- Sampled soundM68K assembly
- Numbers and sizesAssembly basics
XNZVC ●●●●●
- ● set from the result
Forms
Operands
<ea>- An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With
opt p=68020, an allowedd(An,Xn)ord(PC,Xn)mode also permits the corresponding 68020 indexed and memory indirect forms. See 68020 addressing. More
move.b #1, d0
neg.b d0 ; d0 low byte = $FF (-1)
move.l #$80, d1
neg.b d1 ; $80 stays $80: +128 does not fit in a signed byte, so V is set
* --- Negating zero ---
move.l #0, d2
neg.l d2 ; d2 = 0, Z flag set
* --- Size matters ---
move.l #$100, d3
neg.b d3 ; only negates low byte (was $00)