Mitsubishi Electronics FX2C Home Theater Server User Manual


 
FX Series Programmable Controlers Applied Instructions 5
5-25
5.3.1 ADD (FNC 20)
Operation 1:
(Applicable to all units)
The data contained within the source devices
(S
1
,S
2
) is combined and the total is stored at the
specified destination device (D).
Points to note:
a) All calculations are al
g
ebraicall
y
processed, i.e. 5 + (-8)= -3.
b) The same device ma
y
be used as a source (S
1
or S
2
) and as the destination (D). If this is
the case then the ADD instruction would actuall
y
operate continuousl
y
. This means on
ever
y
scan the instruction would add the result of the last scan to the second source device.
To prevent this from happenin
g
the pulse modifier should be used or an interlock should be
pro
g
rammed.
c) If the result of a calculation is “0" then a special auxiliar
y
fla
g
, M8020 is set ON.
d) If the result of an operation exceeds 32,767 (16 bit limit) or 2,147,483,647 (32 bit limit) the
carr
y
fla
g
, M8022 is set ON. If the result of an operation exceeds -32,768 or -2,147,483,648
the borrow fla
g
, M8021 is set ON. When a result exceeds either of the number limits, the
appropriate fla
g
is set ON (M8021 or M8022) and a portion of the carr
y
/borrow is stored in
the destination device. The mathematical si
g
n of this stored data is reflective of the number
limit which has been exceeded, i.e. when -32,768 is exceeded ne
g
ative numbers are stored
in the destination device but if 32,767 was exceeded positive numbers would be stored at
D.
e) If the destination location is smaller than the obtained result, then onl
y
the portion of the
result which directl
y
maps to the destination area will be written, i.e if 25 (decimal) was the
result, and it was to be stored at K1Y4 then onl
y
Y4 and Y7 would be active. In binar
y
terms
this is equivalent to a decimal value of 9 a lon
g
wa
y
short of the real result of 25!
Continued over the pa
g
e....
Mnemonic Function
Operands
Program steps
S1 S2 D
ADD
FNC 20
(
Addition
)
The value of the
two source
devices is added
and the result
stored in the desti-
nation device
K, H, KnX, KnY, KnM, KnS,
T, C, D, V, Z
KnY, KnM, KnS,
T, C, D, V, Z
ADD, ADDP:
7 steps
DADD,
DADDP:
13 steps
When usin
g
M8023 to add floatin
g
point data,
onl
y
double word (32 bit) data re
g
isters (D) or
constants (K/H) ma
y
be used. See pa
g
e 4-46
for more details re
g
ardin
g
floatin
g
point format.
X0
ADD D 10 D 12
[ S1 ] [ D ]
D 14
[ S2 ]