NEGATE
Multiply the operand by -1.
| Opcode | Bytes | Cycles | Form | Example |
|---|---|---|---|---|
| $37 | 2 | 3 | negate b:_ | negate b:1 |
| $38 | 2 | 3 | negate p:_ | negate p:2 |
| $39 | 2 | 3 | negate i:_ | negate i:4 |
| Condition flag | Output |
|---|---|
| zero (ZF) | If the result is zero, this flag is 1; otherwise it is 0. |
| negative (NF) | If the result is negative, this flag is 1; otherwise it is 0. |
| overflow (OF) | If the negated value exceeds the register's signed range, this flag is 1; otherwise it is 0. |
| carry (CF) | This flag is always 0. |
Notes
-
This operation is equivalent to subtracting the operand from 0 using
subtract. -
Replaces the value of the operand with its two's complement.
-
Two's complement has one extra negative value, for example
pairvalues range from -32768 ($8000) to 32767 ($7fff). For these overflow cases,negatewill leave the value unchanged, settingOFto1to indicate the overflow.