Item number
Application instructions-14
Ladder format
XCG (d1, d2, n)
Instruction format
XCG (d1, d2, n)
Usable I/O
Exchange destination
d1
head I/O
d2 Exchange source head I/O
Number of bits (words)
n
to be exchanged
Function
•
Exchanges the contents of the n bits from d1 to d1 + n - 1 and the contents between d2 and d2 + n - 1.
•
Bits are exchanged with bits and words are exchanged with words.
n bits (words)
d1+n-1
d2+n-1
If n is a word:
The contents (0 to 255) of the lower 8 bits (b7 to b0) of n (WX, WY, WR, WM, TC) are set to the
number of bits (words) to be exchanged.
If n is a constant:
0 to 255 (decimal) can be designated for the number of bits (words) to be exchanged.
Notes
•
Use this instruction so that d1 + n − 1 and d2 + n - 1 do not exceed the I/O range (R7BF, M3FFF, WRFFF, and WM3FF). If they
exceeds the I/O range, DER is equal to '1' and the exchange is performed up to the maximum range with respect to the smaller number of
bits (words) specified in d1 and d2.
•
If n is equal to "0," the block exchange is not performed and DER (R7F4) will be set to "0."
Program example
X00001 DIF1
Program description
•
When X00001 rises, the contents of WM000 to WM0FF are exchanged with the contents of WM100 to WM1FF.
Processing time (µs) (Average)
n
Bit
1
139
16
338
32
528
64
918
128
1899
255
3695
Name
Condition code
R7F4
R7F3
R7F2
DER
ERR
SD
↕
Number of steps
Condition
Bit
R,
TD, SS,
X
Y
M
CU, CT
WX WY
d1
d2
XCG (WM000, WM100, 256)
Word
120
159
207
284
449
779
5-86
Chapter 5 Instruction Specifications
Block exchange (EXCHANGE)
Processing time (µs)
R7F1
R7F0
Average Maximum
V
C
As per the table
below.
Steps
4
Word
Double word
WR,
DR,
WM TC DX DY
DM
LD
X00001
AND DIF1
[
XCG (WM000, WM100, 256)
]
Remark
Other
The constant is set in
decimal.