2 Instructions
2-254
CP1E CPU Unit Instructions Reference Manual(W483)
Function
SWAP(637) switches the position of the two
bytes in all of the words in the range of mem-
ory from R1 to R1+N-1.
Hint
• This instruction can be used to reverse the order of ASCII-code characters in each word.
Sample program
When CIO 0.00 is ON in the following example, SWAP(637) switches the data in the leftmost bytes with
the data in the rightmost bytes in each word in the 10-word range from W0 to W9.
N
R1
Byte position is swapped.
SWAP
&10
W0
078
15
4 1 4 2
4 3 4 4
4 5 4 6
3 0 3 1
078
15
4 2 4 1
4 4 4 3
4 6 4 5
3 1 3 0
W0
W1
W2
to
W9
W0
W1
W2
to
W9
N
R1
to to
0.00