Mitsubishi Electronics FXCPU Video Game Controller User Manual


 
9 Applied Instructions (Arithmetic and Logical Operation)
9.2 SUBP / Subtraction
172
FXCPU Structured Programming Manual
[Basic & Applied Instruction]
Function and operation explanation
1. 16-bit operation(SUBP)
The data specified by is subtracted from the data specified by in the binary format, and the
subtraction result is transferred to .
The most significant bit of each piece of data indicates the sign (positive: 0 or negative: 1), and data is
subtracted algebraically.
(5-(-8)=13)
When a constant (K) is specified in or , it is automatically converted into the binary format.
2. 32-bit operation(DSUB, DSUBP)
The data specified by is subtracted from the data specified by in the binary format, and the
subtraction result is transferred to .
The most significant bit of each piece of data indicates the sign (positive: 0 or negative: 1), and data is
subtracted algebraically.
(5,500-(-8,540)=14,040)
When a constant (K) is specified in or , it is automatically converted into the binary format.
Extension function(FXU and FX2C PLCs)
The FXU PLC of V2.30 or earlier does not support the extension function.
When executing an instruction with M8023 ON, a binary float operation takes place.
In this case, K, H and D are valid as the object device for and and D is valid for .
The source data needs to be converted into binary float value in advance by FLT instruction.
Note, however, that constants K and H are automatically converted into binary float values.
Related device
1. Relationship between the flag operation and the sign
For the flag operations, refer to Section 1.3.4.
Device Name Description
M8020 Zero
ON : When the operation result is 0
OFF : When the operation result is not 0
M8021 Borrow
ON : When the operation result is less than -32,768 (in 16-bit operation) or -2,147,483,648 (in
32-bit operation), the borrow flag operates.
OFF : When the operation result is not less than -32,768 (in 16-bit operation) or
-2,147,483,648 (in 32-bit operation)
M8022 Carry
ON : When the operation result is more than 32,767 (in 16-bit operation) or 2,147,483,647 (in
32-bit operation), the carry flag operates.
OFF : When the operation result is not more than 32,767 (in 16-bit operation) or
2,147,483,647(in 32-bit operation)
SUBP
EN
s1
s2
ENO
d
Command input
Subtraction
data 1
Device storing
the subtraction
result
Subtraction
data 2
ds1 s2
Command input
Device storing
the subtraction
result
DSUB
EN
s1
s2
ENO
d
s1 s2 s2
[ +1, ] – [ +1, ] [ +1, ]
s1 d d
Subtraction
data 1
Subtraction
data 2
Zero flag
Borrow flag
Zero flag
Borrow flag
The most significant
bit of data
becomes "1".
Zero flag
Carry flag
Zero flag
Carry flag
Zero flag
Zero flag
The most significant
bit of data
becomes "0".
–1, 0, 1
–2, –1, 0, –32,768
32,767, 0, 1, 2
2, –1, 0, –2,147,483,648
–1, 0, 1
2,147,483,647, 0, 1, 2