Instruction Set
4-246
XCHG
Exchange Components
XCHG
What It Does
XCHG exchanges one component with another component.
Syntax
Description
XCHG exchanges two operands. The operands can be in either order.
Operation It Performs
Flag Settings After Instruction
Examples
This example exchanges an integer in one register with an integer in another register.
Form
Opcode
Description
Clocks
Am186 Am188
XCHG AX,
r16
90+
rw
Exchange word register with AX
3
3
XCHG
r16,AX
90+
rw
Exchange AX with word register
3
3
XCHG
r/m8,r8
86
/r
Exchange byte register with r/m byte
4/17
4/17
XCHG
r8,r/m8
86
/r
Exchange r/m byte with byte register
4/17
4/17
XCHG
r/m16,r16
87
/r
Exchange word register with r/m word
4/17
4/21
XCHG
r16,r/m16
87
/r
Exchange r/m word with word register
4/17
4/21
XCHG
component1,component2
/* save first component */
temp =
component1;
/* copy second component to first component */
component1 = component2;
/* copy saved component to second component */
component2 = temp;
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
–
–
–
–
–
– res – res – res –
; exchange BX with CX
MOV
BX,-300
; BX = -300
MOV
CX,700
; CX = 700
XCHG
BX,CX
; BX = 700, CX = -300
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...