Wiki source code of 03 Arithmetic operation

Last modified by Wecon on 2025/09/03 21:03

Show last authors
1 == ADD/16-bit addition operation ==
2
3 **ADD(P)**
4
5 Add the BIN 16-bit data specified in (S1) and the BIN 16-bit data specified in (S2), and store the result in the device specified in (D).
6
7 -[ADD (S1) (S2) (D)]
8
9 **Content, range and data type**
10
11 |Parameter|Content|Range|Data type|Data type (label)
12 |(S1)|Addition operation data or the device storing the addition data|-32768 to 32767|Signed BIN16|ANY16_S
13 |(S2)|Addition operation data or the device storing the addition data|-32768 to 32767|Signed BIN16|ANY16_S
14 |(D)|Device for storing operation results| |Signed BIN16|ANY16_S
15
16 **Device used**
17
18 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="11" %)**Devices**|(((
19 **Offset modification**
20 )))|(((
21 **Pulse extension**
22 )))
23 |KnX|KnY|KnM|KnS|T|C|D|R|SD|K|H|[D]|XXP
24 |(% rowspan="3" %)ADD|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●|●
25 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●|●
26 |Parameter 3| |●|●|●|●|●|●|●|●| | |●|●
27
28 **Features**
29
30 Add the BIN 16-bit data specified in (S1) and the BIN 16-bit data specified in (S2), and store the result of the addition in the device specified in (D).
31
32 (% style="text-align:center" %)
33 [[image:07-1 Basic instructions_html_8e14b2921161f2d9.png]]
34
35 **Related device **
36
37 |Devices|Name|Content
38 |SM151|Carry|When the operation result exceeds 32,767, the carry flag will be (ON).
39 |SM152|Borrow|When the operation result is less than -32,768, the borrow flag will be (ON).
40 |SM153|Zero point|When the operation result is 0, the zero flag will be (ON).
41
42 (% style="text-align:center" %)
43 [[image:07-1 Basic instructions_html_f7e7b9fa9918e937.png]]
44
45 ✎**Note: **
46
47 1.When the source operand and destination operand are specified as the same device:
48
49 The source operand and destination operand can also be specified as the same device number.
50
51 In this case, if you use continuous execution instructions (ADD, DADD), the result of the addition operation will change every operation cycle.
52
53 2.The difference between the ADD instruction and the INC instruction using the +1 addition operation program:
54
55 ADD[P] means that every time X001 changes from OFF to ON, the content of D0 is added by one operation.
56
57 Although this instruction is very similar to the INCP instruction described later, there are some differences in the following content.
58
59 |(% colspan="3" %) |ADD/ADDP/DADD/DADDP instructions|INC/INCP/DINC/DINCP instructions
60 |(% colspan="3" %)**Flag bit (zero, borrow, carry)**|Action|No action
61 |(% rowspan="4" %)Calculation result|(% rowspan="2" %)(((
62 16-bit
63
64 operation result
65 )))|(S) + (+1) = (D)|32767 → 0 → +1 → +2 →|32767→-32768→-32767
66 |(S) + (-1) = (D)|← -2 ← -1 ← 0 ← -32768|——
67 |(% rowspan="2" %)(((
68 32-bit
69
70 operation result
71 )))|(S) + (+1) = (D)|2147483647 → 0 → +1 → +2 →|2147483647 → -2147483648→ -2147483647
72 |(S) + (-1) = (D)|← -2 ← -1 ← 0 ← -2147483648|——
73
74 **Error code**
75
76 |Error code|Content
77 |4085H|The output results of (S1) and (S2) in the read application instruction exceed the device range
78 |4086H|The output result of (D) in the write application instruction exceeds the device range
79
80 **Example**
81
82 (% style="text-align:center" %)
83 [[image:07-1 Basic instructions_html_c88107d9dc85e273.png]]
84
85 Add 10 to the data in (D0), and store the operation result in (D2), that is, (D0) + 10 → (D2).
86
87 == DADD/32-bit addition operation ==
88
89 **DADD(P)**
90
91 Add the BIN32-bit data specified in (S1) and the BIN32-bit data specified in (S2), and store the result in the device specified in (D).
92
93 -[DADD (S1) (S2) (D)]
94
95 **Content, range and data type**
96
97 |Parameter|Content|Range|Data type|Data type (label)
98 |(S1)|Addition data or the device storing the addition data|-2147483648 to 2147483647|Signed BIN32|ANY32_S
99 |(S2)|Addition data or the device storing the addition data|-2147483648 to 2147483647|Signed BIN32|ANY32_S
100 |(D)|Device for storing operation results| |Signed BIN32|ANY32_S
101
102 **Device used**
103
104 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="13" %)**Devices**|(((
105 **Offset modification**
106 )))|(((
107 **Pulse extension**
108 )))
109 |KnX|KnY|KnM|KnS|T|C|D|R|SD|LC|HSC|K|H|[D]|XXP
110 |(% rowspan="3" %)DADD|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
111 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
112 |Parameter 3| |●|●|●|●|●|●|●|●| | | | |●|●
113
114 **Features**
115
116 Add the BIN32-bit data specified in (s1) and the BIN32-bit data specified in (s2), and store the result of the addition in the device specified in (d).
117
118 (% style="text-align:center" %)
119 [[image:07-1 Basic instructions_html_97cb91594c5ae7e4.png]]
120
121 **Related device **
122
123 |Devices|Name|Content
124 |SM151|Carry|When the operation result exceeds 32,767, the carry flag will be (ON).
125 |SM152|Borrow|When the operation result is less than -32,768, the borrow flag will be (ON).
126 |SM153|Zero point|When the operation result is 0, the zero flag will be (ON).
127
128 (% style="text-align:center" %)
129 [[image:07-1 Basic instructions_html_1e2ca6723b868fb4.png]]
130
131 (% class="box infomessage" %)
132 (((
133 ✎**Note: **
134
135 ~1. When the source operand and destination operand are specified as the same device:
136
137 The source operand and destination operand can also be specified as the same device number.
138
139 In this case, if you use continuous execution instructions (ADD, DADD), the result of the addition operation will change every operation cycle. Please note.
140
141 2. The difference between the ADD instruction and the INC instruction using the +1 addition operation program:
142
143 ADD[P] means that every time X001 changes from OFF to ON, the content of D0 is added by one operation.
144
145 Although this instruction is very similar to the INCP instruction described later, there are some differences in the following content.
146 )))
147
148 |(% colspan="3" %) |ADD/ADDP/DADD/DADDP instructions|INC/INCP/DINC/DINCP instructions
149 |(% colspan="3" %)**Flag bit (zero, borrow, carry)**|Action|No action
150 |(% rowspan="4" %)Calculation result|(% rowspan="2" %)(((
151 16-bit
152
153 Operation result
154 )))|(S) + (+1) = (d)|32767→0→+1→+2→|32767→-32768→-32767
155 |(S) + (-1) = (d)|←-2←-1←0←-32768|——
156 |(% rowspan="2" %)(((
157 33-Bit
158
159 operation result
160 )))|(S) + (+1) = (d)|2147483647→0→+1→+2→|2147483647→-2147483648→-2147483647
161 |(S) + (-1) = (d)|←-2←-1←0←-2147483648|——
162
163 **Error code**
164
165 |Error code|Content
166 |4085H|The output results of (S1) and (S2) in the read application instruction exceed the device range
167 |4086H|The output result of (D) in the write application instruction exceeds the device range
168
169 **Example**
170
171 (% style="text-align:center" %)
172 [[image:07-1 Basic instructions_html_de63c4a952dfb6d.png]]
173
174 Add 100000 to the data in (D1, D0), and store the result of the operation in (D3, D2), that is, (D1, D0) + 100000 → (D3, D2).
175
176 == SUB/16-bit subtraction operation ==
177
178 **SUB(P)**
179
180 Subtract the BIN 16-bit data specified in (S1) and the BIN 16-bit data specified in (S2), and store the result in the device specified in (D).
181
182 -[SUB (S1) (S2) (D)]
183
184 **Content, range and data type**
185
186 |Parameter|Content|Range|Data type|Data type (label)
187 |(S1)|The subtraction data or the device storing the subtraction data|-32768 to 32767|Signed BIN16|ANY16_S
188 |(S2)|The subtraction data or the device storing the subtraction data|-32768 to 32767|Signed BIN16|ANY16_S
189 |(D)|Device for storing calculation results| |Signed BIN16|ANY16_S
190
191 **Device used**
192
193 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="11" %)**Devices**|(((
194 **Offset modification**
195 )))|(((
196 **Pulse extension**
197 )))
198 |KnX|KnY|KnM|KnS|T|C|D|R|SD|K|H|[D]|XXP
199 |(% rowspan="3" %)SUB|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●|●
200 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●|●
201 |Parameter 3| |●|●|●|●|●|●|●|●| | |●|●
202
203 **Features**
204
205 Subtract the BIN 16-bit data specified in (S1) and the BIN 16-bit data specified in (S2), and store the result of the operation in the device specified in (D).
206
207 (% style="text-align:center" %)
208 [[image:07-1 Basic instructions_html_cbd3a6fd4cb00b65.png]]
209
210 **Related device **
211
212 |Devices|Name|Content
213 |SM151|Carry|When the operation result exceeds 32,767, the carry flag will be (ON).
214 |SM152|Borrow|When the operation result is less than -32,768, the borrow flag will be (ON).
215 |SM153|Zero point|When the operation result is 0, the zero flag will be (ON).
216
217 (% style="text-align:center" %)
218 [[image:07-1 Basic instructions_html_ac1f8acda3746b1d.png]]
219
220 ✎**Note: **
221
222 ~1. When the source operand and destination operand are specified as the same device:
223
224 The source operand and destination operand can also be specified as the same device number.
225
226 In this case, if continuous execution type instructions (SUB, DSUB) are used, the result of the subtraction operation will change every operation cycle. Please be careful.
227
228 2. The difference between the SUB(P) instruction and the -(P) instruction and DEC(P) instruction executed by the -1 subtraction program
229
230 SUB(P) instruction every time X1 changes from OFF to ON, the program of D0 content -1 is similar to -(P) instruction and DEC(P) instruction described later, but the following contents are different.
231
232 |(% colspan="3" %) |SUB/SUBP/DSUB/DSUBP instructions|DEC/DECP/DDEC/DDECP instructions
233 |(% colspan="3" %)**Flag bit (zero, borrow, carry)**|Action|No action
234 |(% rowspan="4" %)Calculation result|(% rowspan="2" %)16-bit operation result|(S)-(+1)=(D)|←-2←-1←0←-32768|-32768→+32767→32766
235 |(S)-(-1)=(D)|+32767→0→+1→+2→|——
236 |(% rowspan="2" %)32-bit operation result|(S)-(+1)=(D)|←-2←-1←0←-2147483648|-2147483648→2147483647→2147483646
237 |(S)-(-1)=(D)|2147483647→0→+1→+2→|——
238
239 **Error code**
240
241 |Error code|Content
242 |4085H|The output results of (S1) and (S2) in the read application instruction exceed the device range
243 |4086H|The output result of (D) in the write application instruction exceeds the device range
244
245 **Example**
246
247 (% style="text-align:center" %)
248 [[image:07-1 Basic instructions_html_bda57d807670bde2.png||height="74" width="372"]]
249
250 Subtract 10 from the data in D0, and store the calculation result in D2, that is, (D0)-10 → (D2).
251
252 == DSUB/32-bit subtraction operation ==
253
254 **DSUB(P)**
255
256 Subtract the BIN32-bit data specified in (S1) and the BIN32-bit data specified in (S2), and store the result in the device specified in (D).
257
258 -[DSUB (S1) (S2) (D)]
259
260 **Content, range and data type**
261
262 |Parameter|Content|Range|Data type|Data type (label)
263 |(S1)|The subtraction data or the device storing the subtraction data|-2147483648 to 2147483647|Signed BIN32|ANY32_S
264 |(S2)|The subtraction data or the device storing the subtraction data|-2147483648 to 2147483647|Signed BIN32|ANY32_S
265 |(D)|Device for storing calculation results| |Signed BIN32|ANY32_S
266
267 **Device used**
268
269 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="13" %)**Devices**|(((
270 **Offset modification**
271 )))|(((
272 **Pulse extension**
273 )))
274 |KnX|KnY|KnM|KnS|T|C|D|R|SD|LC|HSC|K|H|[D]|XXP
275 |(% rowspan="3" %)DSUB|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
276 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
277 |Parameter 3| |●|●|●|●|●|●|●|●|●|●| | |●|●
278
279 **Features**
280
281 Subtract the BIN32-bit data specified in (S1) and the BIN32-bit data specified in (S2), and store the result of the operation in the device specified in (D).
282
283 (% style="text-align:center" %)
284 [[image:07-1 Basic instructions_html_f37d57bb2a3d8fad.png]]
285
286 Related device
287
288 |Devices|Name|Content
289 |SM151|Carry|When the operation result exceeds 2,147,483,647, the carry flag will be ON.
290 |SM152|Borrow|When the operation result is less than -2,147,483,648, the borrow flag will be ON.
291 |SM153|Zero point|When the operation result is 0, the zero flag will be ON.
292
293 (% style="text-align:center" %)
294 [[image:07-1 Basic instructions_html_f61b250c2dec5a2c.png]]
295
296 ✎**Note: **
297
298 ~1. When the source operand and destination operand are specified as the same device:
299
300 The source operand and destination operand can also be specified as the same device number.
301
302 In this case, if continuous execution type instructions (SUB, DSUB) are used, the result of the subtraction operation will change every operation cycle. Please be careful.
303
304 2. The difference between the SUB(P) instruction and the -(P) instruction and DEC(P) instruction executed by the -1 subtraction program
305
306 SUB(P) instruction every time X1 changes from OFF to ON, the program of D0 content -1 is similar to -(P) instruction and DEC(P) instruction described later, but the following contents are different.
307
308 |(% colspan="3" %) |SUB/SUBP/DSUB/DSUBP instructions|DEC/DECP/DDEC/DDECP instructions
309 |(% colspan="3" %)**Flag bit (zero, borrow, carry)**|Action|No action
310 |(% rowspan="4" %)Calculation result|(% rowspan="2" %)16-bit operation result|(S)-(+1)=(D)|←-2←-1←0←-32768|-32768→32767→32766
311 |(S)-(-1)=(D)|+32767→0→+1→+2→|——
312 |(% rowspan="2" %)32-bit operation result|(S)-(+1)=(D)|←-2←-1←0←-2147483648|-2147483648→2147483647→2147483646
313 |(S)-(-1)=(D)|+2147483647→0→+1→+2→|——
314
315 **Error code**
316
317 |Error code|Content
318 |4085H|The output results of (S1) and (S2) in the read application instruction exceed the device range
319 |4086H|The output result of (D) in the write application instruction exceeds the device range
320
321 **Example**
322
323 (% style="text-align:center" %)
324 [[image:07-1 Basic instructions_html_e0a9b7ee38c72d67.png||height="77" width="447"]]
325
326 Subtract 100000 from the data in (D1,D0), and store the result of the operation in (D3,D2), that is, (D1,D0)-10000 → (D3,D2).
327
328 == MUL/16-bit multiplication ==
329
330 **MUL(P)**
331
332 Multiply the BIN16 bits specified in (S1) with the BIN16 bits specified in (S2), and store the result in the device specified in (D).
333
334 -[MUL (S1) (S2) (D)]
335
336 **Content, range and data type**
337
338 |Parameter|Content|Range|Data type|Data type (label)
339 |(S1)|Multiplication operation data or the device storing multiplication operation data|-32768 to 32767|Signed BIN 16 bit|ANY16_S
340 |(S2)|Multiplication operation data or the device storing multiplication operation data|-32768 to 32767|Signed BIN 16 bit|ANY16_S
341 |(D)|Device for storing calculation results| |Signed BIN 32 bit|ANY32_S
342
343 **Device used**
344
345 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="13" %)**Devices**|(((
346 **Offset modification**
347 )))|(((
348 **Pulse extension**
349 )))
350 |KnX|KnY|KnM|KnS|T|C|D|R|SD|LC|HSC|K|H|[D]|XXP
351 |(% rowspan="3" %)MUL|Parameter 1|●|●|●|●|●|●|●|●|●| | |●|●|●|●
352 |Parameter 2|●|●|●|●|●|●|●|●|●| | |●|●|●|●
353 |Parameter 3| |●|●|●|●|●|●|●|●|●|●| | |●|●
354
355 **Features**
356
357 Multiply the BIN 16-bit data specified in (S1) with the BIN 16-bit data specified in (S2), and store the result of the operation in the device specified in (D).
358
359 (% style="text-align:center" %)
360 [[image:07-1 Basic instructions_html_7bc795b98291521f.png]]
361
362 (D) is the multiplication result in the case of bit device
363
364 • K1: lower 4 bits (B0 to B3)
365
366 • K4: Lower 16 bits (B0 to B15)
367
368 • K8: Lower 32 bits (B0 to B31)
369
370 **Error code**
371
372 |Error code|Content
373 |4085H|The output results of (S1) and (S2) in the read application instruction exceed the device range
374 |4086H|The output result of (D) in the write application instruction exceeds the device range
375
376 **Example**
377
378 [[image:07-1 Basic instructions_html_a72970708460f454.png||height="71" width="378"]]
379
380 Multiply the data in (D0) by (D2), and store the operation result in (D5, D4), that is, (D0) × (D2) → (D5, D4).
381
382 == DMUL/32-bit multiplication ==
383
384 **DMUL(P)**
385
386 Multiply the 32-bit BIN specified in (S1) and the 32-bit BIN specified in (S2), and store the result in the device specified in (D).
387
388 -[DMUL (S1) (S2) (D)]
389
390 **Content, range and data type**
391
392 |Parameter|Content|Range|Data type|Data type (label)
393 |(S1)|Multiplication operation data or device storing multiplication operation data|-2147483648 to 2147483647|Signed BIN 32 bit|ANY32_S
394 |(S2)|Multiplication operation data or device storing multiplication operation data|-2147483648 to 2147483647|Signed BIN 32 bit|ANY32_S
395 |(D)|Device for storing calculation results| |Signed BIN64 bit|ANY64_S
396
397 **Device used**
398
399 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="13" %)**Devices**|(((
400 **Offset modification**
401 )))|(((
402 **Pulse extension**
403 )))
404 |KnX|KnY|KnM|KnS|T|C|D|R|SD|LC|HSC|K|H|[D]|XXP
405 |(% rowspan="3" %)DMUL|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
406 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
407 |Parameter 3| |●|●|●|●|●|●|●|●|●|●| | |●|●
408
409 **Features**
410
411 Multiply the BIN32-bit data specified in (S1) and the BIN32-bit data specified in (S2), and store the result of the operation in the device specified in (D).
412
413 (% style="text-align:center" %)
414 [[image:07-1 Basic instructions_html_1d28943293a84978.png]]
415
416 (D) is the multiplication result in the case of bit device
417
418 • K1: lower 4 bits (B0 to B3)
419
420 • K4: Lower 16 bits (B0 to B15)
421
422 • K8: Lower 32 bits (B0 to B31)
423
424 **Error code**
425
426 |Error code|Content
427 |4085H|The output results of (S1) and (S2) in the read application instruction exceed the device range
428 |4086H|The output result of (D) in the write application instruction exceeds the device range
429
430 **Example**
431
432 (% style="text-align:center" %)
433 [[image:07-1 Basic instructions_html_d0ed498dee1bbd2b.png||height="70" width="356"]]
434
435 Multiply the data in (D1, D0) by (D3, D2), and store the result of the operation in ((D7, D6), (D5, D4)), ie (D1, D0) × (D3, D2) → ((D7, D6), (D5, D4)).
436
437 == DIV/16-bit division operation ==
438
439 **DIV(P)**
440
441 Divide the BIN 16-bit data specified in (S1) with the BIN 16-bit data specified in (S2), and store the result in the device specified in (D).
442
443 -[DIV (S1) (S2) (D)]
444
445 **Content, range and data type**
446
447 |Parameter|Content|Range|Data type|Data type (label)
448 |(S1)|Division operation data or device storing division operation data|-32768 to 32767|Signed BIN 16 bit|ANY16_S
449 |(S2)|Division operation data or device storing division operation data|-32768 to 32767|Signed BIN 16 bit|ANY16_S
450 |(D)|Device for storing calculation results| |Signed BIN 32 bit|ANY32_S
451
452 **Device used**
453
454 |(% rowspan="2" %)**Instruction**|(% rowspan="2" style="width:130px" %)**Parameter**|(% colspan="13" style="width:569px" %)**Devices**|(% style="width:147px" %)(((
455 **Offset modification**
456 )))|(((
457 **Pulse extension**
458 )))
459 |(% style="width:25px" %)KnX|KnY|KnM|KnS|T|C|D|R|SD|LC|HSC|K|(% style="width:56px" %)H|(% style="width:147px" %)[D]|XXP
460 |(% rowspan="3" %)DIV|(% style="width:130px" %)Parameter 1|(% style="width:25px" %)●|●|●|●|●|●|●|●|●| | |●|(% style="width:56px" %)●|(% style="width:147px" %)●|●
461 |(% style="width:130px" %)Parameter 2|(% style="width:25px" %)●|●|●|●|●|●|●|●|●| | |●|(% style="width:56px" %)●|(% style="width:147px" %)●|●
462 |(% style="width:130px" %)Parameter 3|(% style="width:25px" %) |●|●|●|●|●|●|●|●|●|●| |(% style="width:56px" %) |(% style="width:147px" %)●|●
463
464 **Features**
465
466 Divide the BIN 16-bit data specified in (S1) with the BIN 16-bit data specified in (S2), and store the result of the operation in the device specified in (D).
467
468 (% style="text-align:center" %)
469 [[image:07-1 Basic instructions_html_5b6a7b9968539f80.png||class="img-thumbnail"]]
470
471 In the case of a word device, the division result uses a 32-bit storage quotient and remainder, and in the case of a bit device, only a 16-bit storage quotient is used.
472
473 • Quotient is stored in the lower 16 bits.
474
475 • The remainder is stored in the upper 16 bits. (Can only be stored in the case of word devices.)
476
477 ✎**Note**
478
479 ~1. About the opearation result
480
481 • The highest bit of the quotient and remainder represents the sign of positive (0) and negative (1).
482
483 • When one of (S1) or (S2) is negative, the quotient becomes negative. When (S1) is negative, the remainder becomes negative.
484
485 2. The device specified by (D)
486
487 • With the digit specification function, when specifying a bit device, the remainder cannot be obtained.
488
489 **Error code**
490
491 |Error code|Content
492 |4080H|The input of divisor (S2) is 0
493 |4085H|The output results of (S1) and (S2) in the read application instruction exceed the device range
494 |4086H|The output result of (D) in the write application instruction exceeds the device range
495
496 **Example**
497
498 (% style="text-align:center" %)
499 [[image:07-1 Basic instructions_html_7966aef8d2143e29.png]]
500
501 Divide the data in (D0) by (D2), and store the result of the calculation: the quotient is stored in (D4), and the remainder is stored in (D5), ie (D0)/(D2) → (D4 (quotient)) (D5 ( remainder)).
502
503 == DDIV/32-bit division operation ==
504
505 **DDIV(P)**
506
507 Divide the BIN32-bit data specified in (S1) with the BIN32-bit data specified in (S2), and store the result in the device specified in (D).
508
509 -[DDIV (S1) (S2) (D)]
510
511 **Content, range and data type**
512
513 |Parameter|Content|Range|Data type|Data type (label)
514 |(S1)|Division operation data or device storing division operation data|-2147483648 to 2147483647|Signed BIN 32 bit|ANY32_S
515 |(S2)|Division operation data or device storing division operation data|-2147483648 to 2147483647|Signed BIN 32 bit|ANY32_S
516 |(D)|Device for storing calculation results| |Signed BIN64 bit|ANY64_S
517
518 **Device used**
519
520 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="13" %)**Devices**|(((
521 **Offset modification**
522 )))|(((
523 **Pulse extension**
524 )))
525 |KnX|KnY|KnM|KnS|T|C|D|R|SD|LC|HSC|K|H|[D]|XXP
526 |(% rowspan="3" %)DDIV|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
527 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
528 |Parameter 3| |●|●|●|●|●|●|●|●|●|●| | |●|●
529
530 **Features**
531
532 Divide the BIN32-bit data specified in (S1) with the BIN32-bit data specified in (S2), and store the result of the operation in the device specified in (D).
533
534 (% style="text-align:center" %)
535 [[image:07-1 Basic instructions_html_1b1dca7a3fa22e30.png]]
536
537 In the case of word devices, the division result uses BIN64 bits to store the quotient and remainder. In the case of bit devices, only the BIN 32-bit storage quotient is used.
538
539 ✎**Note: **
540
541 ~1. About the operation result
542
543 • The highest bit of the quotient and remainder represents the sign of positive (0) and negative (1).
544
545 • When one of (S1) or (S2) is negative, the quotient becomes negative. When (S1) is negative, the remainder becomes negative.
546
547 2. The specified device of (D)
548
549 • With the digit specification function, when a bit device is specified, the remainder cannot be obtained.
550
551 **Error code**
552
553 |Error code|Content
554 |4080H|The input of divisor (S2) is 0
555 |4085H|The output results of (S1) and (S2) in the read application instruction exceed the device range
556 |4086H|The output result of (D) in the write application instruction exceeds the device range
557
558 **Example**
559
560 (% style="text-align:center" %)
561 [[image:07-1 Basic instructions_html_21e85706527efeba.png]]
562
563 Divide the data in (D1, D0) by (D3, D2), and store the result of the calculation: the quotient is stored in (D5, D4), and the remainder is stored in (D7, D6), that is (D1, D0)/ (D3, D2) → (D5, D4) (quotient) (D7, D6) (remainder).
564
565 == INC/16-bit data increment ==
566
567 **INC(P)**
568
569 Add one to the device (BIN 16-bit data) specified in (D).
570
571 -[INC (D)]
572
573 **Content, range and data type**
574
575 |Parameter|Content|Range|Data type|Data type (label)
576 |(D)|The word device number that stores the data added by one|-32768 to 32767|Signed BIN 16 bit|ANY16_S
577
578 **Device used**
579
580 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="8" %)**Devices**|(((
581 **Offset modification**
582 )))|(((
583 **Pulse extension**
584 )))
585 |KnY|KnM|KnS|T|C|D|R|SD|[D]|XXP
586 |INC|Parameter 1|●|●|●|●|●|●|●|●|●|●
587
588 **Features**
589
590 Add one to the device (BIN 16-bit data) specified in (D).
591
592 (% style="text-align:center" %)
593 [[image:07-1 Basic instructions_html_f35c36e39c08072.png]]
594
595 • If the INC(P) instruction is executed when the content of the device specified in (D) is 32767, -32768 will be stored in the device specified in (D).
596
597 • Flags (zero, borrow, carry) do not perform actions.
598
599 ✎**Note: ** If the continuous execution (INC) instruction is used, the addition operation will be performed every operation cycle, so care should be taken.
600
601 **Error code**
602
603 |Error code|Content
604 |4085H|The output results of (D) in the read application instruction exceed the device range
605 |4086H|The output result of (D) in the write application instruction exceeds the device range
606
607 **Example**
608
609 (% style="text-align:center" %)
610 [[image:07-1 Basic instructions_html_4fe585ed449771bf.png||height="88" width="349"]]
611
612 Add one to the device value specified in D0, that is, (D0) + 1 → (D0).
613
614 == DINC/32-bit data increment ==
615
616 **DINC(P)**
617
618 Add one to the device (BIN 32-bit data) specified in (D).
619
620 -[DINC (D)]
621
622 **Content, range and data type**
623
624 |Parameter|Content|Range|Data type|Data type (label)
625 |(D)|The word device number that stores the data added by one|-2147483648 to 2147493647|Signed BIN 32 bit|ANY32_S
626
627 **Device used**
628
629 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
630 **Offset modification**
631 )))|(((
632 **Pulse extension**
633 )))
634 |KnY|KnM|KnS|T|C|D|R|SD|LC|HSC|[D]|XXP
635 |DINC|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
636
637 **Features**
638
639 Add one to the device (BIN 32-bit data) specified in (D).
640
641 (% style="text-align:center" %)
642 [[image:07-1 Basic instructions_html_7d13add7bbac367d.png]]
643
644 • When the DINC(P) instruction is executed when the content of the device specified in (D) is 2147483647, -2147483648 will be stored in the device specified in (D).
645
646 • Flags (zero, borrow, carry) do not perform actions.
647
648 ✎**Note: ** If the continuous execution (INC) instruction is used, the addition operation will be performed every operation cycle, so care should be taken.
649
650 **Error code**
651
652 |Error code|Content
653 |4085H|The output results of (D) in the read application instruction exceed the device range
654 |4086H|The output result of (D) in the write application instruction exceeds the device range
655
656 **Example**
657
658 (% style="text-align:center" %)
659 [[image:07-1 Basic instructions_html_9288e451278259f.png||height="83" width="330"]]
660
661 Add one to the device value specified in (D1, D0), that is, (D1, D0) + 1 → (D1, D0).
662
663
664
665
666
667
668
669
670 **DEC/16 bit data decrement**
671
672 **DEC(P)**
673
674 Minus one for the device (BIN 16-bit data) specified in (D).
675
676 -[DEC (D)]
677
678 **Content, range and data type**
679
680 |Parameter|Content|Range|Data type|Data type (label)
681 |(D)|The word device number that stores the data minus by one|-32768 to 32767|Signed BIN 16 bit|ANY16_S
682
683 **Device used**
684
685 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="8" %)**Devices**|(((
686 **Offset modification**
687 )))|(((
688 **Pulse extension**
689 )))
690 |KnY|KnM|KnS|T|C|D|R|SD|[D]|XXP
691 |DEC|Parameter 1|●|●|●|●|●|●|●|●|●|●
692
693 **Features**
694
695 Minus one for the device (BIN 16-bit data) specified in (D).
696
697 [[image:07-1 Basic instructions_html_df1a004773f12e76.png]]
698
699 • If the DEC(P) instruction is executed when the content of the device specified in (D) is -32768, 32767 will be stored in the device specified in (D).
700
701 • Flags (zero, borrow, carry) do not perform actions.
702
703 ✎**Note: ** If using continuous execution (DEC) instructions, subtraction will be performed every operation cycle, so care should be taken.
704
705 **Error code**
706
707 |Error code|Content
708 |4085H|The output results of (D) in the read application instruction exceed the device range
709 |4086H|The output result of (D) in the write application instruction exceeds the device range
710
711 **Example**
712
713 (% style="text-align:center" %)
714 [[image:07-1 Basic instructions_html_ebee4e241b873490.png||height="108" width="423"]]
715
716 Each time M0 is set, the value of the device specified in D0 will be -1, (D0)-1 → (D0).
717
718 == DDEC/32-bit data decrement ==
719
720 **DDEC(P)**
721
722 Minus one for the device (BIN 32-bit data) specified in (D).
723
724 -[DDEC (D)]
725
726 **Content, range and data type**
727
728 |Parameter|Content|Range|Data type|Data type (label)
729 |(D)|The word device number that stores the data minus by one|-2147483648 to 2147483647|Signed BIN 32 bit|ANY32_S
730
731 **Device used**
732
733 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
734 **Offset modification**
735 )))|(((
736 **Pulse extension**
737 )))
738 |KnY|KnM|KnS|T|C|D|R|SD|LC|HSC|[D]|XXP
739 |DDEC|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
740
741 **Features**
742
743 Minus one for the device (BIN 32-bit data) specified in (D).
744
745 (% style="text-align:center" %)
746 [[image:07-1 Basic instructions_html_7d13add7bbac367d.png]]
747
748 If the DDEC(P) instruction is executed when the content of the device specified in (D) is 0, minus one will be stored in the device specified in (D).
749
750 • Flags (zero, borrow, carry) do not perform actions.
751
752 ✎**Note: ** If using continuous execution (DEC) instructions, subtraction will be performed every operation cycle.
753
754 **Error code**
755
756 |Error code|Content
757 |4085H|The output results of (D) in the read application instruction exceed the device range
758 |4086H|The output result of (D) in the write application instruction exceeds the device range
759
760 **Example**
761
762 (% style="text-align:center" %)
763 [[image:07-1 Basic instructions_html_2f77792f36a8d549.png||height="72" width="323"]]
764
765 Minus one on the device value specified in (D1, D0), that is, (D1, D0)-1 → (D0).