CHAPTER 11 INSTRUCTION SET
259
User’s Manual U10676EJ3V0UM
XCH A, @HL
Function:
A
↔
(HL)
Exchanges the contents of the A register with the contents of the data memory addressed by register pair HL.
XCH A, @HL+
Function:
A
↔
(HL), L
←
L+1
skip if L = 0H
Exchanges the contents of the A register with the contents of the data memory addressed by register pair HL. Then,
the contents of the L register are automatically incremented by one, and if the contents of the L register become 0H
as a result, the next instruction is skipped.
XCH A, @HL–
Function:
A
↔
(HL), L
←
L–1
skip if L = FH
Exchanges the contents of the A register with the contents of the data memory addressed by register pair HL. Then,
the contents of the L register are automatically decremented by one, and if the contents of the L register become
FH as a result, the next instruction is skipped.
XCH A, @rpa1
Function:
A
↔
(rpa)
Where rpa = HL+: skip if L = 0
Where rpa = HL–: sKIP if L = FH
Exchanges the contents of the A register with the contents of the data memory addressed by register pair rpa (HL,
HL+, HL–, DE, or DL). If autoincrement (HL+) or autodecrement (HL–) is specified as rpa, the contents of the L register
are automatically incremented or decremented by one after the data have been exchanged. If the result is 0 in the
case of HL+ and FH in the case of HL–, the next instruction is skipped.
Application example
To exchange the data at data memory addresses 20H to 2FH with the data at addresses 30H to 3FH
SEL
MB0
MOV
D, #2
MOV
HL, #30H
LOOP: XCH
A, @HL
; A
↔
(3
×
)
XCH
A, @DL
; A
↔
(2
×
)
XCH
A, @HL+
; A
↔
(3
×
)
BR
LOOP