
Instruction Set
4-163
NEG
Two’s Complement Negation
NEG
What It Does
NEG changes the sign of an integer.
Syntax
Description
NEG replaces the value of a register or memory operand with its two’s complement. The
operand is subtracted from zero and the result is placed in the operand.
NEG sets CF if the operand is not zero. If the operand is zero, it is not changed and NEG
clears CF.
Operation It Performs
Flag Settings After Instruction
Form
Opcode
Description
Clocks
Am186 Am188
NEG
r/m8
F6
/3
Perform a two’s complement negation of r/m byte
3/10
3/10
NEG
r/m16
F7
/3
Perform a two’s complement negation of r/m word
3/10
3/14
NEG
integer
if (
integer == 0)
/* clear carry flag */
CF = 0;
else
/* set carry flag
CF = 1;
/* change sign of integer */
integer = 0 - integer;
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
Processor Status
Flags Register
reserved
OF DF
IF TF SF ZF
AF
PF
CF
? = undefined; – = unchanged
OF=1 if result larger than destination operand
OF=0 otherwise
AF=1 if carry or borrow to low nibble
AF=0 otherwise
PF=1 if low byte of result has even number of set bits
PF=0 otherwise
CF=1 if operand is not equal to 0
CF=0 if operand is equal to 0
–
–
–
res
res
res
SF=1 if result is 0 or positive
SF=0 if result is negative
ZF=1 if result equal to 0
ZF=0 if result not equal to 0
Summary of Contents for Am186 Series
Page 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Page 10: ...Table of Contents x...
Page 18: ...Programming 1 8...
Page 40: ...Instruction Set Listing 3 14...