NEG AX
6-245
NEG AX Negate AX Register
SYNTAX OPTIONS OPCODE OBJMODE RPT CYC
NEG AX 1111 1111 0101 110A X − 1
Operands AX Accumulator high (AH) or accumulator low (AL) register
Description Replace the contents of the specified AX register with the negative of AX:
if(AX = 0x8000)
{
AX = 0x8000;
V flag = 1;
}
else
AX = −AX;
if(AX = 0x0000)
C flag = 1;
else
C flag = 0;
Flags and
Modes
N
After the operation, if bit 15 of AX is 1, then the negative flag bit is set;
otherwise, it is cleared.
Z
After the operation, if AX is 0, then the Z bit is set, otherwise it is cleared.
C
If AX is 0, C is set; otherwise, it is cleared.
V
If AX is 0x8000 at the start of the operation, then this is considered an overflow
and V is set. Otherwise V is not affected.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example
; Take the absolute value of VarA:
MOV AL,@VarA ; Load AL with contents of VarA
NEG AL ; If Al = 8000h, then V = 1
SB NoOverflow,NOV ; Branch and save −AL if no overflow
MOV @VarA,0x7FFFh ; Save 7FFF if overflow
NoOverflow:
MOV @VarA,AL ; Save NEG AL if no overflow