The text of a manual · part 34 of 68
DL405 User Manual: Chapter 5: Standard RLL Instructions, pages 293 to 302
Pages 293 to 302 of 608, from DL405 User Manual
The original document is the PDF (8.2 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the AutomationDirect D4-08B-1, AutomationDirect D4-08ND3S, AutomationDirect D4-16TA, PLC Direct D4-16TD2, AutomationDirect D4-32ND3-1, Konnect-It D4-08B-1, Koyo D4-08B-1, Konnect-It D4-08ND3S, and 6 more models
Page 293
5--121
Standard RLL Instructions Bit Operation Instructions
Bit Operation Instructions The Sum instruction counts number of bits that are set to “1” in the accumulator. The HEX result resides in the accumulator.
Sum (SUM)
SUM
430 440 450
DS
HPP
In the following example, when X1 is on, the value formed by discrete locations X10--X17 is loaded into the accumulator using the Load Formatted instruction. The number of bits in the accumulator set to “1” is counted using the Sum instruction. The value in the accumulator is copied to V1500 using the Out instruction. DirectSOFT
X17 X16 X15 X14 X13 X12 X11 X10
X1
LDF
ON ON OFF OFF ON OFF ON ON
X10 K8
The unused accumulator bits are set to zero
Load the value represented by discrete locations X10--X17 into the accumulator Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
1
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
Acc. 0
SUM
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
0
0
0
5
0
0
0
0
1
Sum the number of bits in the accumulator set to “1”
OUT V1500
V1500
Copy the value in the lower 16 bits of the accumulator to V1500
Handheld Programmer Keystrokes STR
X(IN)
1
LD
SHFT
F
X(IN)
SHFT
S
U
M
OUT
V
1
5
1
0
0
0
K(CON)
8
Standard RLL Instructions
DL405 User Manual, 4th Edition
Page 294
5--122
Standard RLL Instructions Bit Operation Instructions
Shift Left is a 32 bit instruction that shifts the bits in the accumulator a specified number (Aaaa) of places to the left. The vacant positions are filled with zeros and the bits shifted out of the accumulator are lost.
Shift Left (SHFL)
430 440 450
DS
HPP
Operand Data Type
SHFL A aaa
DL430 Range
DL440 Range
A aaa aaa
DL450 Range aaa
V--memory
V
All (See p. 3--40)
All (See p. 3--41)
All (See p. 3--42)
Constant
K
1--32
1--32
1--32
In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the accumulator using the Load Double instruction. The bit pattern in the accumulator is shifted 2 bits to the left using the Shift Left instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. DirectSOFT
V1401
X1
6
LDD
7
0
V1400 5
3
1
0
1
V1400 Load the value in V1400 and V1401 into the accumulator SHFL
Acc.
K2 The bit pattern in the accumulator is shifted 2 bit positions to the left
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
1
0
0
0
0
0
0
1
1
1
0
0
1
1
1
0
0
0
0
0
1
0
1
0
0
1
1
0
0
0
Shifted out of the accumulator
0
S S
S S
OUTD V1500 Copy the value in the accumulator to V1500 and V1501
Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
1 0
0
0
0
0
1
0
0
4
0
4
0
0
1 0
1 0
1
0
9
Standard RLL Instructions
X(IN)
1
LD
SHFT
D
SHFT
S
H
OUT
SHFT
D
0
0
C
1
4
0
SHFT
V
1
4
0
F
L
SHFT
K(CON)
2
SHFT
V
1
5
0
DL405 User Manual, 4th Edition
1 0
0
1 0
0
0
1
1
0
0
0
1
0
C
V1501
Handheld Programmer Keystrokes STR
0
V1500
0
0
0
0
Page 295
5--123
Standard RLL Instructions Bit Operation Instructions
Shift Right is a 32 bit instruction that shifts the bits in the accumulator a specified number (Aaaa) of places to the right. The vacant positions are filled with zeros and the bits shifted out of the accumulator are lost.
Shift Right (SHFR)
430 440 450
DS
HPP
Operand Data Type
SHFR A aaa
DL430 Range
DL440 Range
A aaa aaa
DL450 Range aaa
V--memory
V
All (See p. 3--40)
All (See p. 3--41)
All (See p. 3--42)
Constant
K
1--32
1--32
1--32
In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the accumulator using the Load Double instruction. The bit pattern in the accumulator is shifted 2 bits to the right using the Shift Right instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. DirectSOFT
V1401
X1
Constant 6
LDD
7
0
V1400 5
3
1
0
1
V1400 Load the value in V1400 and V1401 into the accumulator SHFR
Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
1
0
0
0
0
0
1
1
1
0
0
1
1
1
0
0
0
0
0
1
0
1
0
0
1
1
0
0
0
0
0
K2 The bit pattern in the accumulator is shifted 2 bit positions to the right
S S
S S
Shifted out of the accumulator
OUTD V1500 Acc.
Copy the value in the accumulator to V1500 and V1501
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
1
0
0
0
0
C
4
0
0
0
1 0
1 0
0 1
0
1
1 0
1 0
1 0
9
C
1
V1501
0
0
0
0
0
1 0
0
1
0
0
1
1
0
4
0
0
V1500
Handheld Programmer Keystrokes X(IN)
1
LD
SHFT
D
SHFT
S
OUT
SHFT
SHFT
V
1
4
0
H
F
R
SHFT
K(CON)
2
D
SHFT
V
1
5
0
0
Standard RLL Instructions
STR
0
DL405 User Manual, 4th Edition
Page 296
5--124
Standard RLL Instructions Bit Operation Instructions
Rotate Left is a 32 bit instruction that rotates the bits in the accumulator a specified number (Aaaa) of places to the left.
Rotate Left (ROTL)
ROTL A aaa
430 440 450
DS
HPP
Operand Data Type
DL430 Range
DL440 Range
A aaa aaa
DL450 Range aaa
V--memory
V
All (See p. 3--40)
All (See p. 3--41)
All (See p. 3--42)
Constant
K
1--32
1--32
1--32
In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the accumulator using the Load Double instruction. The bit pattern in the accumulator is rotated 2 bit positions to the left using the Rotate Left instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. DirectSOFT X1
V1401
LDD
6
V1400
7
0
V1400 5
3
1
0
1
Load the value in V1400 and V1401 into the accumulator ROTL K2
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
1
0
0
0
0
0
0
1
Acc.
1
1
0
0
1
1
1
0
0
0
0
0
1
0
1
0
0
1
1
0
0
0
The bit pattern in the accumulator is rotated 2 bit positions to the left
0
S S
S S
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
1 0
0
0
0
0
1
0
1
4
0
5
OUTD V1500 Copy the value in the accumulator to V1500 and V1501
Acc.
0
0
1 0
1 0
1
0
9
Standard RLL Instructions
X(IN)
1
LD
SHFT
D
SHFT
R
O
OUT
SHFT
D
0
0
C
1
4
V1501
Handheld Programmer Keystrokes STR
0
SHFT
V
1
4
0
T
L
SHFT
K(CON)
2
SHFT
V
1
5
0
DL405 User Manual, 4th Edition
0
1 0
0
1 0
0
0
1
1
0
0
0
1
0
C
V1500
0
0
0
0
Page 297
5--125
Standard RLL Instructions Bit Operation Instructions
Rotate Right is a 32 bit instruction that rotates the bits in the accumulator a specified number (Aaaa) of places to the right.
Rotate Right (ROTR)
430 440 450
DS
HPP
Operand Data Type
ROTR A aaa
DL430 Range
DL440 Range
A aaa aaa
DL450 Range aaa
V--memory
V
All (See p. 3--40)
All (See p. 3--41)
All (See p. 3--42)
Constant
K
1--32
1--32
1--32
In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the accumulator using the Load Double instruction. The bit pattern in the accumulator is rotated 2 bit positions to the right using the Rotate Right instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. DirectSOFT
V1401
X1
LDD
6
7
0
V1400 5
3
1
0
1
V1400 Load the value in V1400 and V1401 into the accumulator ROTR
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
1
0
0
0
0
0
0
1
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
1
0
0
0
0
C
4
0
Acc.
K2
1
1
0
0
The bit pattern in the accumulator is rotated 2 bit positions to the right
1
1
S S
1
0
0
0
0
0
1
0
1
0
0
1
1
0
0
0
S S
OUTD V1500 Copy the value in the accumulator to V1500 and V1501
Acc.
1 0
0
1 0
1 0
0 1
0
5
1
LD
SHFT
D
SHFT
R
OUT
SHFT
1 0
9
C
1
SHFT
V
1
4
0
O
T
R
SHFT
K(CON)
2
D
SHFT
V
1
5
0
0
0
0
0
0
1 0
0
1
0
0
1
1
0
4
0
0
V1500
0
Standard RLL Instructions
X(IN)
1 0
V1501
Handheld Programmer Keystrokes STR
1 0
0
DL405 User Manual, 4th Edition
Page 298
5--126
Standard RLL Instructions Bit Operation Instructions
The Encode instruction encodes the bit position in the accumulator having a value of 1, and returns the appropriate binary representation. If the most significant bit is set to 1 (Bit 31), the Encode instruction would place the value HEX 1F (decimal 31) in the accumulator. If the value to be encoded is 0000 or 0001, the instruction will place a zero in the accumulator. If the value to be encoded has more than one bit position set to a “1”, the least significant “1” will be encoded and SP53 will be set on. SP53 will also be set on when the accumulator is equal to zero.
Encode (ENCO)
430 440 450
DS
HPP
ENCO
Discrete Bit Flags
Description
SP53
On when the value of the operand is larger than the accumulator can work with. SP53 will also come on when the accumulator is zero.
NOTE: The status flags are only valid until another instruction that uses the same flags is executed. In the following example, when X1 is on, The value in V1400 is loaded into the accumulator using the Load instruction. The bit position set to a “1” in the accumulator is encoded to the corresponding 5 bit binary value using the Encode instruction. The value in the lower 16 bits of the accumulator is copied to V1500 using the Out instruction. DirectSOFT
V1400
X1
1
0
0
0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
0
0
0
0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
1
0
0
0
0
0
C
LD V1400 Load the value in V1400 into the lower 16 bits of the accumulator Acc.
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
Bit postion 12 is converted to binary ENCO
Encode the bit position set to “1” in the accumulator to a 5 bit binary value
Acc.
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
Standard RLL Instructions
OUT V1500 Copy the value in the lower 16 bits of the accumulator to V1500
V1500
Handheld Programmer Keystrokes STR
X(IN)
1
LD
V
1
4
0
SHFT
E
N
C
O
OUT
V
1
5
0
DL405 User Manual, 4th Edition
0
0
Binary value for 12.
Page 299
5--127
Standard RLL Instructions Bit Operation Instructions
The Decode instruction decodes a 5 bit binary value of 0--31 (0--1F HEX) in the accumulator by setting the appropriate bit position to a 1. If the accumulator contains the value F (HEX), bit 15 will be set in the accumulator. If the value to be decoded is greater than 31, the number is divided by 32 until the value is less than 32 and then the value is decoded.
Decode (DECO)
430 440 450
DS
HPP
DECO
In the following example when X1 is on, the value formed by discrete locations X10--X14 is loaded into the accumulator using the Load Formatted instruction. The five bit binary pattern in the accumulator is decoded by setting the corresponding bit position to a “1” using the Decode instruction. DirectSOFT
X14 X13 X12 X11 X10
X1
LDF
OFF ON OFF ON ON
X10 K5
Load the value in represented by discrete locations X10--X14 into the accumulator Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
The binary value is converted to bit position 11.
DECO
Decode the five bit binary pattern in the accumulator and set the corresponding bit position to a “1”
Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
Handheld Programmer Keystrokes STR
X(IN)
1
LD
SHFT
F
SHFT
X(IN)
SHFT
D
E
C
O
1
0
SHFT
K(CON)
5
Standard RLL Instructions
DL405 User Manual, 4th Edition
Page 300
5--128
Standard RLL Instructions Number Conversion Instructions
Number Conversion Instructions The Binary instruction converts a BCD value in the accumulator to the equivalent binary value. The result resides in the accumulator.
Binary (BIN)
430 440 450
DS
HPP
BIN
In the following example, when X1 is on, the value in V1400 and V1401 is loaded into the accumulator using the Load Double instruction. The BCD value in the accumulator is converted to the binary (HEX) equivalent using the BIN instruction. The binary value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. The handheld programmer would display the binary value in V1500 and V1501 as a HEX value. DirectSOFT
V1401
X1
LDD
V1400
0
0
0
2
8
5
2
9
V1400 Load the value in V1400 and V1401 into the accumulator 8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
Acc. 0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
1
0
1
0
0
1
0
1
0
0
1
BCD Value
28529 = 16384 + 8192 + 2048 + 1024 + 512 + 256 + 64 + 32 + 16 + 1 Binary Equivalent Value
BIN
Convert the BCD value in the accumulator to the binary equivalent value
Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
0
1
1
1
0
0
0
1
2 1 4 7 4 4 8 3 6 4 8
1 0 7 3 7 4 1 8 2 4
5 3 6 8 7 0 9 1 2
2 6 8 4 3 5 4 5 6
1 3 4 2 1 7 7 2 8
6 7 1 0 8 8 6 4
3 3 5 5 4 4 3 2
1 6 7 7 7 2 1 6
8 3 8 8 6 0 8
4 1 9 4 3 0 4
2 0 9 7 1 5 2
1 0 4 8 5 7 6
5 2 4 2 8 8
2 6 2 1 4 4
1 3 1 0 7 2
6 5 5 3 6
3 2 7 6 8
1 6 3 8 4
8 1 9 2
4 0 9 6
2 0 4 8
1 0 2 4
5 1 2
2 5 6
1 6 2 4 8
3 2
1 8 6
4
2
1
0
0
6
F
7
1
OUTD V1500 0
Standard RLL Instructions
Copy the binary value in the accumulator to V1500 and V1501
Handheld Programmer Keystrokes STR
X(IN)
1
LD
SHFT
D
SHFT
V
1
4
0
0
SHFT
D
SHFT
V
1
5
0
0
BIN OUT
DL405 User Manual, 4th Edition
0
V1501
V1500
The binary (HEX) value copied to V1500
Page 301
5--129
Standard RLL Instructions Number Conversion Instructions
The Binary Coded Decimal instruction converts a binary value in the accumulator to a BCD value. The result resides in the accumulator.
Binary Coded Decimal (BCD)
BCD
430 440 450
DS
HPP
In the following example, when X1 is on, the binary (HEX) value in V1400 and V1401 is loaded into the accumulator using the Load Double instruction. The binary value in the accumulator is converted to the BCD equivalent value using the BCD instruction. The BCD value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. DirectSOFT
V1401
X1
0
LDD
0
0
V1400 0
6
F
7
1
Binary Value
V1400 Load the value in V1400 and V1401 into the accumulator
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
0
1
1
1
0
0
0
1
2 1 4 7 4 4 8 3 6 4 8
1 0 7 3 7 4 1 8 2 4
5 3 6 8 7 0 9 1 2
2 6 8 4 3 5 4 5 6
1 3 4 2 1 7 7 2 8
6 7 1 0 8 8 6 4
3 3 5 5 4 4 3 2
1 6 7 7 7 2 1 6
8 3 8 8 6 0 8
4 1 9 4 3 0 4
2 0 9 7 1 5 2
1 0 4 8 5 7 6
5 2 4 2 8 8
2 6 2 1 4 4
1 3 1 0 7 2
6 5 5 3 6
3 2 7 6 8
1 6 3 8 4
8 1 9 2
4 0 9 6
2 0 4 8
1 0 2 4
5 1 2
2 5 6
1 6 2 4 8
3 2
1 8 6
4
2
1
Acc.
BCD
16384 + 8192 + 2048 + 1024 + 512 + 256 + 64 + 32 + 16 + 1 = 28529
Convert the binary value in the accumulator to the BCD equivalent value
BCD Equivalent Value 8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
1
0
1
0
0
1
0
1
0
0
1
0
0
0
2
8
5
2
9
Acc.
OUTD V1500 Copy the BCD value in the accumulator to V1500 and V1501
V1501
V1500
The BCD value copied to V1500 and V1501
Handheld Programmer Keystrokes X(IN)
1
LD
SHFT
D
SHFT
V
1
4
0
0
SHFT
D
SHFT
V
1
5
0
0
Standard RLL Instructions
STR
BCD OUT
DL405 User Manual, 4th Edition
Page 302
5--130
Standard RLL Instructions Number Conversion Instructions
The Invert instruction inverts or takes the one’s complement of the 32 bit value in the accumulator. The result resides in the accumulator.
Invert (INV)
430 440 450
DS
HPP
INV
In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the accumulator using the Load Double instruction. The value in the accumulator is inverted using the Invert instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. DirectSOFT
V1401
X1
0
LDD
4
0
V1400 5
0
2
5
0
V1400 Load the value in V1400 and V1401 into the accumulator
Acc.
INV Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
1
0
0
1
1
0
0
0
0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
1
1
1
0
0
1
1
1
0
1
0
1
0
1
0
1
1
0
0
1
0
1
0
0
1
1
0
1
0
1
0
1
1
0
1
0
0
1
0
1
B
F
A
F
0
0
0
1
1
1
D
A
F
Invert the binary bit pattern in the accumulator
F
OUTD V1500
V1501
Copy the value in the accumulator to V1500 and V1501
Handheld Programmer Keystrokes STR
X(IN)
1
SHFT
D
SHFT
I
N
V
OUT
SHFT
D
SHFT
Standard RLL Instructions
LD SHFT
DL405 User Manual, 4th Edition
V
1
4
0
0
V
1
5
0
0
V1500
0
1
0
1
0
0
1
1