The text of a manual · part 30 of 68
Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual: SECTION 5 Instruction Set, pages 264 to 273
Pages 264 to 273 of 613, from Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual
The original document is the PDF (3.8 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.
Filed in the catalog under the Omron C200H-SP001 and Omron C200HW-PA204
Page 264
Section 5-19
Symbol Math Instructions 00000 –L(411)
Address
Instruction
DM 0100
00000
LD
DM 0110
00001
–L(411)
Operands 00000
DM 0120
DM 0100
–CL(413)
DM 0120
DM 0110 00001 DM 0200
00002
LD
DM 0210
00003
–CL(413)
00001 DM 0200
DM 0220
DM 0210 DM 0220
Program Example 2
Example (unsigned data): 20F55A10 – B8A360E3 = –97AE06D3. In this example, the eight-digit binary value in IR 121 and IR 120 is subtracted from the value in IR 201 and IR 200, and the result is output to eight-digit binary in DM 0101 and DM 0100. If the result is negative, the instruction at (2) will be executed, and the actual result will then be output to DM 0101 and DM 0100. The Carry Flag (SR 25504) will be turned ON, so the actual number is –97AE06D3. Because the content of DM 0101 and DM 0100 is negative, CY is used to turn ON a self-holding bit that turns ON a bit indicating a negative value.
00002
TR0
(411) –L SR 255 04 (CY)
200
120
DM 0100
1
(411) –L
DM 0000
DM 0100
DM 0100
Address
Instruction
00000
LD
00002
00001
OUT
TR0
00002
–L(411)
2
Operands
200 120
SR 255 04 (CY)
DM 0100
02100
“–” display 02100
00003
LD
00004
AND
00005
–L(411)
TR0 SR 25504 DM 0000 DM 0100 DM 0100
00006
LD
00007
AND
SR 25504
TR0
00008
OR
02100
00009
OUT
02100
Subtraction at 1 Mi+1: IR 201
– CY 1
Mi: IR 200
2 0 F 5
5 A 1 0
Su+1: IR 121
Su: IR 120
B 8 A 3
6 0 E 3
R+1: DM 0101 R+1: DM 0100 6 8 5 1
F 9 2 D
The Carry Flag (SR 25504) is ON, so the result is subtracted from 0000 0000 (the contents of DM 0000 and DM 0001) to obtain the actual result.
252
Page 265
Section 5-19
Symbol Math Instructions Subtraction at 2 Mi+1: DM 0001
Mi: DM 0000
0 0 0 0
0 0 0 0
Su+1: DM 0101
Su: DM 0100
6 8 5 1
F 9 2 D
–
R+1: DM 0101 R+1: DM 0100
CY 1
9 7 A E
0 6 D 3
Final Subtraction Result Mi+1: IR 201
– CY 1
Mi: IR 200
2 0 F 5
5 A 1 0
Su+1: DM 0101
Su: DM 0100
6 8 5 1
F 9 2 D
R+1: DM 0101 R+1: DM 0100 9 7 A E
0 6 D 3
5-19-4 BCD Subtraction: –B(414)/ –BL(415)/–BC(416)/–BCL(417) BCD SUBTRACT WITHOUT CARRY: –B(414) Ladder Symbols
Operand Data Areas Mi: Minuend word
–B(414)
@–B(414)
Mi
Mi
Su
Su
R
R
IR, SR, AR, DM, EM, HR, TC, LR, # Su: Subtrahend word IR, SR, AR, DM, EM, HR, TC, LR, # R: Result word IR, SR, AR, DM, EM, HR, LR
DOUBLE BCD SUBTRACT WITHOUT CARRY: –BL(415) Ladder Symbols
Operand Data Areas Mi: 1st minuend word
–BL(415)
@–BL(415)
Mi
Mi
Su
Su
R
R
IR, SR, AR, DM, EM, HR, TC, LR Su: 1st subtrahend word IR, SR, AR, DM, EM, HR, TC, LR R: 1st result word IR, SR, AR, DM, EM, HR, LR
253
Page 266
Section 5-19
Symbol Math Instructions BCD SUBTRACT WITH CARRY: –BC(416) Ladder Symbols
Operand Data Areas Mi: Minuend word
–BC(416)
@–BC(416)
Mi
Mi
Su
Su
R
R
IR, SR, AR, DM, EM, HR, TC, LR, # Su: Subtrahend word IR, SR, AR, DM, EM, HR, TC, LR, # R: Result word IR, SR, AR, DM, EM, HR, LR
DOUBLE BCD SUBTRACT WITH CARRY: –BCL(417) Ladder Symbols
Operand Data Areas Mi: 1st minuend word
–BCL(417)
@–BCL(417)
Mi
Mi
Su
Su
R
R
IR, SR, AR, DM, EM, HR, TC, LR Su: 1st subtrahend word IR, SR, AR, DM, EM, HR, TC, LR R: 1st result word IR, SR, AR, DM, EM, HR, LR
Description
BCD SUBTRACT WITHOUT CARRY When the execution condition is OFF, –B(414) is not executed. When the execution condition is ON, –B(414) subtracts the BCD contents of Su from Mi, and places the result in R. If the result is negative, CY is set and the 10’s complement of the actual result is placed in R. To convert the 10’s complement to the true result, subtract the content of R from 0000. Mi
–
Su
CY
R
DOUBLE BCD SUBTRACT WITHOUT CARRY When the execution condition is OFF, –BL(415) is not executed. When the execution condition is ON, –BL(415) subtracts the 8-digit BCD content of Su and Su+1 from the 8-digit BCD content in Mi and Mi+1, and places the result in R and R+1. If the result is negative, CY is set and the 10’s complement of the actual result is placed in R. To convert the 10’s complement to the true result, subtract the content of R from 0000 0000. Mi + 1
Mi
–
Su + 1
Su
CY
R+1
R
BCD SUBTRACT WITH CARRY When the execution condition is OFF, –BC(416) is not executed. When the execution condition is ON, –BC(416) subtracts the BCD contents of Su and CY from Mi, and places the result in R. If the result is negative, CY is set and the 10’s
254
Page 267
Section 5-19
Symbol Math Instructions complement of the actual result is placed in R. To convert the 10’s complement to the true result, subtract the content of R from 0000. Mi
–
Su
–
CY
CY
R
DOUBLE BCD SUBTRACT WITH CARRY When the execution condition is OFF, –BCL(417) is not executed. When the execution condition is ON, –BCL(417) subtracts CY and the 8-digit BCD content of Su and Su+1 from the 8-digit BCD content in Mi and Mi+1, and places the result in R and R+1. If the result is negative, CY is set and the 10’s complement of the actual result is placed in R. To convert the 10’s complement to the true result, subtract the content of R from 0000 0000. Mi + 1
Mi
Su + 1
Su
– CY
CY R+1
R
Precautions
Mi and Su (or Mi, Mi+1, Su, and Su+1) must be BCD. If any other data is used, the Error Flag (SR 25503) will turn ON and the instruction will not be executed.
Flags
ER:
Mi and Su (or Mi, Mi+1, Su, and Su+1) are not BCD. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
CY: EQ:
The result exceeds the digits. The result after the subtraction is all zeros.
Example
–BL Operation When IR 00000 is ON in the following example, the content of DM 0111 and DM 0110 is subtracted from the content of DM 0101 and DM 0100, and the result is output in eight-digit BCD to DM 0121 and DM 0120. CY is set if the result is negative –BCL Operation When IR 00001 is ON in the following example, the content of DM 0211 and DM 0210 are subtracted from the content of DM 0201 and DM 0200, and the result including the carry is output in eight-digit BCD to DM 0221 and DM 0220. CY is set if the result is negative
00000 –BL(415) DM 0100 DM 0110
Address
Instruction
00000
LD
00001
–BL(415)
Operands 00000
DM 0120
DM 0100
–BCL(417)
DM 0120
DM 0110 00001 DM 0200
00002
LD
DM 0210
00003
–BCL(417)
DM 0220
00001 DM 0200 DM 0210 DM 0220
Program Example
Example: 9,583,960 – 17,072,641 = –7,488,681. In this example, the eight-digit BCD content of IR 121 and IR 120 is subtracted
255
Page 268
Section 5-19
Symbol Math Instructions from the content of IR 201 and IR 200, and the result is output in eight-digit BCD to DM 0101 and DM 0100. The result is negative, so the instruction at (2) will be executed, and the true value will then be output to DM 0101 and DM 0100. The Carry Flag (SR 25504) will be turned ON, so the actual number is –7,488,681. Because the content of DM 0101 and DM 0100 is negative, CY is used to turn ON a self-holding bit that turns ON a bit indicating a negative value.
00002
TR0
(415) –BL SR 255 04 (CY)
200
120
DM 0100
1
(415) –BL
DM 0000
DM 0100
DM 0100
Address
Instruction
00000
LD
00002
00001
OUT
TR0
00002
–BL(415)
2
Operands
200 120
SR 255 04 (CY)
DM 0100
02100
“–” display 02100
00003
LD
00004
AND
00005
–BL(415)
TR0 SR 25504 DM 0000 DM 0100 DM 0100
00006
LD
00007
AND
SR 25504
TR0
00008
OR
02100
00009
OUT
02100
Subtraction at 1 Mi+1: IR 201
–
Mi: IR 200
0 9 5 8
3 9 6 0
Su+1: IR 121
Su: IR 120
1 7 0 7
2 6 4 1
09583960 + (100000000 – 17072641) CY R+1: DM 0101 R+1: DM 0100 1
9 2 5 1
1 3 1 9
The Carry Flag (SR 25504) is ON, so the result is subtracted from 0000 0000.
Subtraction at 2
–
Mi+1: DM 0001
Mi: DM 0000
0 0 0 0
0 0 0 0
Su+1: DM 0101
Su: DM 0100
9 2 5 1
1 3 1 9
00000000 + (100000000 – 92511319) CY R+1: DM 0101 R+1: DM 0100 1
256
0 7 4 8
8 6 8 1
Page 269
Section 5-19
Symbol Math Instructions Final Subtraction Result Mi+1: IR 201
Mi: IR 200
2 0 F 5
5 A 1 0
Su+1: DM 0101
Su: DM 0100
6 8 5 1
F 9 2 D
– CY 1
R+1: DM 0101 R+1: DM 0100 0 7 4 8
8 6 8 1
5-19-5 Binary Multiplication: *(420)/ *L(421)/*U(422)/*UL(423) SIGNED BINARY MULTIPLY: *(420) Ladder Symbols
Operand Data Areas Md: Multiplicand word
*(420)
@*(420)
Md
Md
Mr
Mr
R
R
IR, SR, AR, DM, EM, HR, TC, LR, # Mr: Multiplier word IR, SR, AR, DM, EM, HR, TC, LR, # R: 1st result word IR, SR, AR, DM, EM, HR, LR
DOUBLE SIGNED BINARY MULTIPLY: *L(421) Ladder Symbols
Operand Data Areas Md: 1st multiplicand word
*L(421)
@*L(421)
Md
Md
Mr
Mr
R
R
IR, SR, AR, DM, EM, HR, TC, LR, # Mr: 1st multiplier word IR, SR, AR, DM, EM, HR, TC, LR, # R: 1st result word IR, SR, AR, DM, EM, HR, LR
UNSIGNED BINARY MULTIPLY: *U(422) Ladder Symbols
Operand Data Areas Md: Multiplicand word
*U(422)
@*U(422)
Md
Md
Mr
Mr
R
R
IR, SR, AR, DM, EM, HR, TC, LR, # Mr: Multiplier word IR, SR, AR, DM, EM, HR, TC, LR, # R: 1st result word IR, SR, AR, DM, EM, HR, LR
257
Page 270
Section 5-19
Symbol Math Instructions DOUBLE UNSIGNED BINARY MULTIPLY: *UL(423) Ladder Symbols
Operand Data Areas Md: 1st multiplicand word
*UL(423)
@*UL(423)
Md
Md
Mr
Mr
R
R
IR, SR, AR, DM, EM, HR, TC, LR Mr: 1st multiplier word IR, SR, AR, DM, EM, HR, TC, LR R: 1st result word IR, SR, AR, DM, EM, HR, LR
Description
SIGNED BINARY MULTIPLY When the execution condition is OFF, *(420) is not executed. When the execution condition is ON, *(420) multiplies the signed content of Md by the signed content of Mr, places the rightmost four digits of the result in R, and places the leftmost four digits in R+1. Md
X R +1
Mr
R
DOUBLE SIGNED BINARY MULTIPLY When the execution condition is OFF, *L(421) is not executed. When the execution condition is ON, *L(421) multiplies the signed 8-digit content of Md and Md+1 by the signed content of Mr and Mr+1, and places the result in R to R+3.
x R+3
R+2
Md + 1
Md
Mr + 1
Mr
R+1
R
UNSIGNED BINARY MULTIPLY When the execution condition is OFF, *U(422) is not executed. When the execution condition is ON, *U(422) multiplies the unsigned content of Md by the unsigned content of Mr, places the rightmost four digits of the result in R, and places the leftmost four digits in R+1. Md
X R +1
Mr
R
DOUBLE UNSIGNED BINARY MULTIPLY When the execution condition is OFF, *UL(423) is not executed. When the execution condition is ON, *UL(423) multiplies the unsigned 8-digit content of Md
258
Page 271
Section 5-19
Symbol Math Instructions and Md+1 by the unsigned content of Mr and Mr+1, and places the result in R to R+3.
x R+3
Flags
Example
R+2
Md + 1
Md
Mr + 1
Mr
R+1
R
ER:
The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
EQ:
The multiplication result is all zeroes.
N:
The leftmost bit (MSB) of word R+1 (or word R+3 for “double” instructions) after the multiplication is “1.”
*L Operation When IR 00000 is ON in the following example, the content of DM 0101 and DM 0100 are multiplied by the content of DM 0111 and DM 0110, in eight-digit binary with sign, and the result is output to DM 0123 through DM 0120. *UL Operation When IR 00001 is ON in the following example, the content of DM 0201 and DM 0200 are multiplied by the content of DM 0211 and DM 0210, in eight-digit binary without sign, and the result is output to DM 0223 through DM 0220. 00000
Address
Instruction
DM 0100
00000
LD
DM 0110
00001
*L(421)
∗L(421)
Operands 00000
DM 0120
DM 0100
∗UL(423)
DM 0120
DM 0110 00001 DM 0200
00002
LD
DM 0210
00003
*UL(423)
00001 DM 0200
DM 0220
DM 0210 DM 0220
5-19-6 BCD Multiplication: *B(424)/ *BL(425) BCD MULTIPLY: *B(424) Ladder Symbols
Operand Data Areas Md: Multiplicand word
*B(424)
@*B(424)
Md
Md
Mr
Mr
R
R
IR, SR, AR, DM, EM, HR, TC, LR, # Mr: Multiplier word IR, SR, AR, DM, EM, HR, TC, LR, # R: 1st result word IR, SR, AR, DM, EM, HR, LR
259
Page 272
Section 5-19
Symbol Math Instructions DOUBLE BCD MULTIPLY: *BL(425) Ladder Symbols
Operand Data Areas Md: 1st multiplicand word
*BL(425)
@*BL(425)
Md
Md
Mr
Mr
R
R
IR, SR, AR, DM, EM, HR, TC, LR Mr: 1st multiplier word IR, SR, AR, DM, EM, HR, TC, LR R: 1st result word IR, SR, AR, DM, EM, HR, LR
Description
BCD MULTIPLY When the execution condition is OFF, *B(424) is not executed. When the execution condition is ON, *B(424) multiplies the BCD content of Md by the BCD content of Mr, and places the result in R and R+1. Md
X R +1
Mr
R
DOUBLE BCD MULTIPLY When the execution condition is OFF, *BL(425) is not executed. When the execution condition is ON, *BL(425) multiplies the 8-digit BCD content of Md and Md+1 by the BCD content of Mr and Mr+1, and places the result in R to R+3.
x R+3
R+2
Md + 1
Md
Mr + 1
Mr
R+1
R
Precautions
Md (Md+1) and Mr (Mr+1) must be BCD. If any other data is used, the Error Flag (SR 25503) will turn ON and the instruction will not be executed.
Flags
ER:
Content of Md (Md+1) or Mr (Mr+1) is not BCD. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
EQ: Example
The multiplication result is all zeroes.
*BL Operation When IR 00000 is ON in the following example, the content of DM 0101 and DM 0100 is multiplied by the content of DM 0111 and DM 0110, in eight-digit BCD, and the result is output to DM 0123 through DM 0120.
00000
Address
Instruction
DM 0100
00000
LD
DM 0110
00001
*BL(425)
∗BL(425)
DM 0120
Operands 00000 DM 0100 DM 0110 DM 0120
260
Page 273
Section 5-19
Symbol Math Instructions
5-19-7 Binary Division: /(430)/ /L(431)//U(432)//UL(433) SIGNED BINARY DIVIDE: /(430) Ladder Symbols
Operand Data Areas Dd: Dividend word
/(430)
@/(430)
Dd
Dd
Dr
Dr
R
R
IR, SR, AR, DM, EM, HR, TC, LR, # Dr: Divisor word IR, SR, AR, DM, EM, HR, TC, LR, # R: 1st result word IR, SR, AR, DM, EM, HR, LR
DOUBLE SIGNED BINARY DIVIDE: /L(431) Ladder Symbols
Operand Data Areas Dd: 1st dividend word
/L(431)
@/L(431)
Dd
Dd
Dr
Dr
R
R
IR, SR, AR, DM, EM, HR, TC, LR Dr: 1st divisor word IR, SR, AR, DM, EM, HR, TC, LR R: 1st result word IR, SR, AR, DM, EM, HR, LR
UNSIGNED BINARY DIVIDE: /U(432) Ladder Symbols
Operand Data Areas Dd: Dividend word
/U(432)
@/U(432)
Dd
Dd
Dr
Dr
R
R
IR, SR, AR, DM, EM, HR, TC, LR, # Dr: Divisor word IR, SR, AR, DM, EM, HR, TC, LR, # R: 1st result word IR, SR, AR, DM, EM, HR, LR
DOUBLE UNSIGNED BINARY DIVIDE: /UL(433) Ladder Symbols
Operand Data Areas Dd: 1st dividend word
/UL(433)
@/UL(433)
Dd
Dd
Dr
Dr
R
R
IR, SR, AR, DM, EM, HR, TC, LR Dr: 1st divisor word IR, SR, AR, DM, EM, HR, TC, LR R: 1st result word IR, SR, AR, DM, EM, HR, LR
Description
SIGNED BINARY DIVIDE When the execution condition is OFF, /(430) is not executed. When the execution condition is ON, /(430) divides the signed binary content of Dd by the signed
261