DL06 Micro PLC User Manual, 3rd Edition, Rev. E
5-170
Chapter 5: Standard RLL Instructions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
A
B
C
D
Swap (SWAP)
The Swap instruction exchanges the data in two tables of equal
length.
Step 1: Load the length of the tables (number of V-memory locations) into the first level of
the accumulator stack. This parameter must be a HEX value, 0 to FF. Remember that
the tables must be of equal length.
Step 2: Load the starting V-memory location for the first table into the accumulator. This
parameter must be a HEX value. You can use the LDA instruction to convert an octal
address to hex.
Step 3: Insert the Swap instruction. This specifies the starting address of the second table.
This parameter must be a HEX value. You can use the LDA instruction to convert an
octal address to hex.
Helpful hint
: — The data swap occurs within a single scan. If the instruction executes on
multiple consecutive scans, it will be difficult to know the actual contents of either table at any
particular time. So, remember to swap just on a single scan.
The example program below uses a PD contact (triggers for one scan for off-to-on transition).
First, we load the length of the tables (two words) into the accumulator. Then we load the
address of the first table (V3000) into the accumulator using the LDA instruction, converting
the octal address to hex. Note that it does not matter which table we declare “first”, because
the swap results will be the same.
A aaa
S WAP
1 2 3 4
5 6 7 8
A B C D
0 0 0 0
V 3000
V 3100
S WAP
Operand Data Type
DL06 Range
aaa
V-memory
V
See memory map
Handheld Programmer Keystrokes
STR
$
SHFT
ANDST
L
3
D
SHFT
RST
S
ANDN
W
0
A
PREV
CV
P
ENT
2
C
0
A
0
A
ENT
SHFT
ANDST
L
3
D
3
D
0
A
0
A
ENT
SHFT
CV
P
SHFT
3
D
0
A
0
A
3
D
1
B
0
A
ENT
DS
Used
HPP Used
DirectSOFT 32
X0
LD
K2
LDA
0 3000
SWAP
0 3100
Load the constant value 2
(Hex.) into the lower 16 bits
of the accumulator.
Convert octal 3000 to HEX
and load the value into the
accumulator. This is the
table beginning.
Swap the contents of the
table in the previous
instruction with the one
at V3100.
DirectSOFT
The example to the right shows a table
of two words at V3000. We will swap its
contents with another table of two words
at 3100 by using the Swap instruction. The
required ladder program is given below.