The text of a manual · part 29 of 36
DL305 User Manual, pages 277 to 286
Pages 277 to 286 of 356
The original document is the PDF (3.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 GE DL330 / D3-330, Fanuc DL330 / D3-330 and GE Fanuc DL330 / D3-330
Page 277
11–39
Instruction Set Math Instructions
Multiply Example
Whenever possible multiplications resulting in more than 4 digits should be avoided since the DL305 instruction set can only manipulate a maximum of two consecutive 8–bit registers (4 digits) at one time. If the result of a multiplication is greater than 4 digits, the application program must be written to compensate for the instruction set 4 digit maximum for data manipulation. The example below shows how the auxiliary accumulator is used to store a result with more than 4 digits and how to access the upper 4 digits. The example below shows how the auxiliary accumulator is used to process numbers larger than 4 digits when the multiplication instruction is used. DirectSOFT Display
Handheld Programmer Keystrokes
000 DSTR (F50) R 402 Load the value in registers R402 and R403 into the accumulator
DOUT (F60) R412
R 402
3
1
3
MUL (F73) K50 Multiply the value in the accumulator with the constant 50
R 403 6
6
X 0
0
1
8
Auxilliary Acc. R 577 R 576
0
9
9
1
9
Accumulator
5
0
Constant (K50)
5
0
Accumulator
0
9
5
0
R 413
R 412
0
1
Output the value in the accumulator to registers R412 and R413
DSTR (F50) R 576 Load the value in registers R576 and R577 into the accumulator
DOUT (F60) R414 Output the value in the accumulator to registers R414 and R415
0
8
Accumulator
0
0
R 415
1
8
R 414
STR F
SHF 5
0 0
ENT ENT
R F SHF
4 7 5
0 3 0
2 ENT ENT
F R F
6 4 5
0 1 0
ENT 2 ENT
R F R
5 6 4
7 0 1
6 ENT 4
ENT
ENT ENT ENT
Instruction Set
The multiply instruction allows you to multiply two 4–digit numbers together. The result is located in the accumulator and the auxiliary accumulator (R576 and R577) when necessary. The accumulator holds the lower 4 digits of the result and the auxiliary accumulator holds the upper 4 digits.
Page 278
Instruction Set
11–40
Instruction Set Math Instructions
Divide DIV (F74)
The Divide (F74) is a 16–bit instruction that divides the value in the accumulator by the value in a 16–bit register, two consecutive 8–bit registers, or a 4–digit BCD value. The integer portion of the result is stored in the accumulator and the decimal fraction is stored in the auxiliary accumulator, R576 and R577. Discrete flags are used to indicate if the dividend or divisor is zero or if only the divisor is zero. Data Type
D3–330 Range
D3–340 Range
DIV (F74) A aaaa
D3–330P Range
A aaaa aaaa aaaa
Inputs / Outputs
R
000–014 070–075
000–014 070–075
000–014 070–075
Control Relays
R
016–036
016–036 100–105
016, 020–027
Shift Registers
R
040–056
040–056
––
Stages
R
––
––
100–116
Timer /Counters (16 bit)
R
600–677
600–677
600–677
Data Registers
R
400–577
400–577 700–777
400–577
Constant (4–digit BCD)
K
0000–9999
0000–9999
0000–9999
Discrete Bit Flags
Description
776
Will be on if the dividend or divisor is zero
777
Will be on if the divisor is zero
In the following example, when input 000 is on the value (530) in R402 and R403 is loaded into the accumulator using the Data Store (F50) instruction. The data in the accumulator is divided by the constant 10 (K10). The result in the accumulator and is copied to data registers R404 and R405 using the Data Out (F60) instruction. The remainder is in the auxiliary accumulator (R576 and R577). DirectSOFT Display
Handheld Programmer Keystrokes
000 DSTR (F50) R 402 Load the value in registers R402 and R403 into the accumulator DIV (F74) K10 Divide the value in the accumulator by the constant value 10
R 403
R 402
0
3
0
0
5
0
0
STR F
SHF 5
0 0
ENT ENT
3
0
Accumulator
R F SHF
4 7 1
0 4 0
2 ENT ENT
1
0
Constant (K10)
F R
6 4
0 0
ENT 4
5
3
Accumulator
0 DOUT (F60) R404
5
0
R 405
5
0
0
0
0
Auxilliary Acc. R 577 R 576
3
R 404
776 Copy the value in the accumulator to registers R404 and R405
Dividend or divisor is zero 777 Divisor is zero
ENT
ENT
Page 279
11–41
Instruction Set Math Instructions
Divide Example
DirectSOFT Display
Handheld Programmer Keystrokes
000 DSTR (F50) R 402 Load the value in registers R402 and R403 into the accumulator DIV (F74) K32 Divide the value in the accumulator with the constant value 32
DOUT (F60) R412
R 403
R 402
0
2
0
0
5
5
0
9
STR F
SHF 5
0 0
ENT ENT
2
9
Accumulator
R F SHF
4 7 3
0 4 2
2 ENT ENT
3
2
Constant (K32)
1
6
2
F R F
6 4 5
0 1 0
ENT 2 ENT
Auxilliary Acc. R 577 R 576
R F
5 6
7 0
6 ENT
ENT
R
4
1
4
ENT
Accumulator
0
0
1
6
R 413
R 412
5
1
Copy the value in the accumulator to registers R412 and R413
DSTR (F50) R 576 Load the value in registers R576 and R577 into the accumulator
DOUT (F60) R414 Copy the value in the accumulator to registers R414 and R415
3
2
Accumulator
5
3
R 415
1
2
R 414
5
3
1
ENT
ENT
Instruction Set
The divide instruction allows you to divide the value in the accumulator by 4 digits maximum. The divide instruction uses the accumulator for the integer value of the result and the auxiliary accumulator (R576 and R577) for fraction. The instruction set only allows manipulation on two consecutive registers at a time. For example, if the result was a 4 digit number with a remainder it would have to be treated like two 4–digit numbers in the program. Manipulating numbers over 4 digits should be avoided whenever possible. If it cannot be avoided the application program must be written to compensate for the 4–digit maximum for data manipulation. The example below shows how the auxiliary accumulator is used to store the fractional portion of the result and how to access the remainder.
Page 280
11–42
Instruction Set Bit Operation Instructions
Instruction Set
Bit Operation Instructions Shift Left SHFL (F81)
The Shift Left (F81) is a 16–bit instruction that shifts the value in the accumulator a specified number of bits (15 maximum) to the left. Discrete bit flags are used to indicate if a “1” was shifted out of the accumulator or if the accumulator equals “0” after the shift. Data Type
SHFL (F81) K aaaa
D3–330 Range
D3–340 Range
D3–330P Range aaaa aaaa aaaa
1–16
1–16
1–16
Constant (4–digit BCD)
K
Discrete Bit Flags
Description
775
Will be on if a“1” was shifted out of the accumulator.
776
Will be on if the accumulator equals zero after the shift instruction is executed.
In the following example, when input 000 is on the value in R000 and R010 is loaded into the accumulator using the Data Store 5 (F55) instruction. The bit pattern in the accumulator is shifted to the left 4 bit positions using the Shift Left (F81) instruction with the result resides in the accumulator. The value in the accumulator is copied to data registers R404 and R405 using the Data Out (F60) instruction. DirectSOFT Display 000
R 010
R 000
Handheld Programmer Keystrokes
6
3
STR F
SHF 5
0 5
ENT ENT
R F SHF
0 8 4
ENT 1 ENT
ENT
F R
6 4
0 0
ENT 4
9
5
DSTR 5 (F55) R0 Load the value in registers R0 and R10 into the accumulator 7
6
0
1
I/O Points 100-107 5 4 3 2 1 0 1
0
1
0
Acc.
1
S S
Shifted out of accumulator
SHFL (F81) K4
0
7
6
0
0
I/O Points 000-007 5 4 3 2 1 0 1
1
0
1
0
1
S S
15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
1
1
0
1
1
0
0
0
5
0
0
0
1
0
0
1
0
0
775 will be ON after the shift 776 will be OFF after the shift
Shift the value in the accumulator 4 bits to the left
9
DOUT (F60) R 404 Copy the value in the accumulator to registers R404 and R405
3
R 405
R 404
775 Shifted a “1” out of Accumulator 776 Accumulator equals zero after shift
ENT
Page 281
11–43
Instruction Set Bit Operation Instructions
The Shift Right (F80) is a 16–bit instruction that shifts the value in the accumulator a specified number of bits (15 maximum) to the right. Discrete bit flags are used to indicate if a “1” was shifted out of the accumulator or if the accumulator equals “0” after the shift. Data Type
Instruction Set
Shift Right SHFR (F80)
SHFR (F80) Kaaaa
D3–330 Range
D3–340 Range
D3–330P Range aaaa aaaa aaaa
1–16
1–16
1–16
Constant (4–digit BCD)
K
Discrete Bit Flags
Description
775
Will be on if a“1” was shifted out of the accumulator.
776
Will be on if the accumulator equals zero after the shift instruction is executed.
In the following example, when input 000 is on the value in R000 and R010 is loaded into the accumulator using the Data Store 5 (F55) instruction. The bit pattern in the accumulator is shifted 4 bit positions using the Shift Right (F80) instruction and the result resides in the accumulator. The value in the accumulator is copied to data registers R404 and R405 using the Data Out (F60) instruction. DirectSOFT Display 000 DSTR 5 (F55) R0 Load the value in registers R0 and R10 into the accumulator
R 10
R0
Handheld Programmer Keystrokes
4
3
STR F
SHF 5
0 5
ENT ENT
R F SHF
0 8 4
ENT 0 ENT
ENT
F R
6 4
0 0
ENT 4
9
7
I/O Points 100-107 6 5 4 3 2 1 0
7
I/O Points 000-007 6 5 4 3 2 1 0
0
1
0
0
0
0
1
0
0
1
S S
SHFR (F80) K4
Acc.
5
1
S S
1
0
1
0
1
Shifted out of accumulator
15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
1
0
1
0
1
1
9
3
0
0
0
0
1
0
0
0
775 will be ON after the shift 776 will be OFF after the shift
Shift the value in the accumulator 4 bits to the right
0
DOUT (F60) R 404 Copy the value in the accumulator to registers R404 and R405
4
R 405
R 404
775 Shifted a “1” out of Accumulator 776 Accumulator equals zero after shift
ENT
Page 282
11–44
Instruction Set Number Conversion Instructions
Instruction Set
Number Conversion Instructions Encode ENCOD (F83)
The Encode instruction encodes the accumulator bit position that contains a 1 by returning the corresponding binary representation. If the most significant bit is set to HEX F (decimal 15), the binary value 15 is returned to the accumulator. If the accumulator value is 0000 or 0001 a zero will be returned to the accumulator. If there is more than one bit position set to a “1” the least significant “1” will be encoded. The discrete bit flag 777 is used to indicate if there were multiple 1s in the accumulator.
ENCOD (F83)
Discrete Bit Flags
Description
777
Will be on if there was more than one bit position set to a ”1” in the accumulator.
Page 283
11–45
Instruction Set Number Conversion Instructions
DirectSOFT Display
Handheld Programmer Keystrokes
000 DSTR 5 (F55) R 005
R 015
R 005
0
4
0
0
Load the value in registers R005 and R015 into the accumulator Acc.
15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
Bit position 6 converted to binary.
ENCOD (F83) Acc.
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
6
0
0
0
0
0
0
0
Encode the bit position in the accumulator set to by returning the corresponding binary number
DOUT3 (F63) R 404 Copy the lower four bits in the accumulator to the lower four bits of register R404.
R 404
STR F
SHF 5
0 5
ENT ENT
R F F R
5 8 6 4
ENT 3 3 0
ENT ENT 4
ENT
Instruction Set
In the following example, when input 000 is on the 16–bit binary pattern from registers R005 and R015 is loaded in the accumulator by the Data Store 5 (F55) instruction. In this example the 6th bit (BCD 40) is on. When the Encode (F83) instruction executes the accumulator will contain the BCD value of 6. The lower four bits of the accumulator are copied to the lower four bits of register R404 by the Data Out 3 (F63) instruction.
Page 284
Instruction Set
11–46
Instruction Set Number Conversion Instructions
Decode DECOD (F82)
The Decode instruction decodes a four bit binary number (0–F) in the accumulator and sets the corresponding bit position to a one. If the accumulator contains a HEX F (decimal 15) the most significant bit (bit 15) will be set in the accumulator. If the accumulator contains a zero the least significant bit (bit 0) will be set to a one. All other bits in the accumulator will be set to a zero.
DECOD (F82)
In the following example, when 000 is on the binary value of the lower four bits in R016 (5) will be loaded in the accumulator by the Data Store 3 (F53) instruction. The Decode instruction will then translate the value 5 to a 1 in the fifth bit position of the accumulator. The value 20 in the accumulator is copied to data registers R404 and R405 with the Data Out (F60) instruction. DirectSOFT Display
Handheld Programmer Keystrokes
000
R 016
DSTR3 (F53) R 016
0
5
Load the lower four bits in R016 into the accumulator
Acc.
15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
Bit pattern equals 5 BCD
DECOD (F82)
Acc.
15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
Decode the binary bit pattern in the accumulator and set the appropriate bit to a "1"
DOUT (F60) R 404 Copy the value in the accumulator to registers R404 and R405
0
0
R 405
R 404
1
0
STR F
SHF 5
0 3
ENT ENT
R F
1 8
6 2
ENT ENT
F R
6 4
0 0
ENT 4
ENT
Page 285
11–47
Instruction Set Number Conversion Instructions
The Binary (F85) instruction converts a BCD value in the accumulator to the binary/HEX equivalent value. The result of the conversion resides in the accumulator.
BIN (F85)
In the following example, when input 000 is on the value (2571 BCD) in R600 is loaded into the accumulator using the Data Store (F50) instruction. The value in the accumulator is converted to a binary number (HEX 0A0B) using the Binary (F85) instruction with the result residing in the accumulator. The value in the accumulator is copied to I/O registers R000 and R010 (which corresponds to I/O points 0–7 and 100–107) with the Data Out 5 (F65) instruction. DirectSOFT Display
Handheld Programmer Keystrokes
000 DSTR (F50) R 600 Load the value in registers 600 and 601 into the accumulator
BIN (F85)
R601
R600
2
7
Accumulator value before BIN instruction
2
Accumulator value after BIN instruction
0
5
5
7
1
1
A
0
B
Hex.
Convert the BCD number in the accumulator to a binary number I/O Points 100-107 DOUT5 (F65) R 000 Output the value in the accumulator to R000 and R010
I/O Points 000-007
7
6
5
4
3
2
1
0
7
6
5
4
3
2
1
0
0
0
0
0
1
0
1
0
0
0
0
0
1
0
1
1
R010
R000
STR F
SHF 5
0 0
ENT ENT
R F F
6 8 6
0 5 5
0 ENT ENT
R
0
ENT
ENT
Instruction Set
Binary BIN (F85)
Page 286
Instruction Set
11–48
Instruction Set Number Conversion Instructions
Binary Coded Decimal BCD (F86)
The Binary Coded Decimal (F86) instruction converts a binary/HEX value in the accumulator to the BCD equivalent. The result of the conversion resides in the accumulator.
BCD (F86)
In the following example, when input 000 is on the value (HEX 0A0A) in R000 and R010 is loaded into the accumulator with the Data Store 5 (F55) instruction. The value in the accumulator is converted to a BCD number (BCD 2570) using the BCD (F86) instruction with the result residing in the accumulator. The value in the accumulator is output to register R600 using the Data Out (F60) instruction.
DirectSOFT Display
R 10
R0
0
0
A
A
Handheld Programmer Keystrokes
000 DSTR5 (F55) R0 Load the value in registers R000 and R010 into the accumulator
Accumulator value before BCD instruction
7
6
0
0
I/O Points 100-107 5 4 3 2 1 0 0
0
1
0
1
0
7
6
0
0
I/O Points 000-007 5 4 3 2 1 0 0
0
1
0
1
0
BCD (F86) Convert the binary number in the accumulator to a BCD number DOUT (F60) R600
15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
1
0
1
0
0
0
0
0
1
0
1
0
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
2
5
7
0
2
5
7
0
Copy the value in the accumulator to R600 and R601
Accumulator value after BCD instruction
R601
R600
STR F
SHF 5
0 5
ENT ENT
R F F
0 8 6
ENT 6 0
ENT ENT
R
6
0
0
ENT