Publication 1763-RM001C-EN-P - October 2009
188
Math Instructions
Using the Math
Instructions
Most math instructions use three parameters, Source A, Source B, and
Destination (additional parameters are described where applicable, later
in this chapter). The mathematical operation is performed using both
Source values. The result is stored in the Destination.
When using math instructions, observe the following:
•
Source and Destination can be different data sizes. Sources are
evaluated at the highest precision (word or long word) of the
operands. Then the result is converted to the size of the destination.
If the signed value of the Source does not fit in the Destination, the
overflow shall be handled as follows:
–
If the Math Overflow Selection Bit is clear, a saturated result is
stored in the Destination. If the Source is positive, the Destination
is +32,767 (word) or +2,147,483,647 (long word). If the result is
negative, the Destination is -32,768 (word) or -2,147,483,648 (long
word).
–
If the Math Overflow Selection Bit is set, the unsigned truncated
value of the Source is stored in the Destination.
•
Sources can be constants or an address, but both sources cannot be
constants.
•
Valid constants are -32,768 to 32,767 (word) and -2,147,483,648 to
2,147,483,647 (long word).
Addressing Modes and File Types can be used as shown in the following
table:
Math Instructions (ADD, SUB, MUL, DIV, NEG, CLR) Valid Addressing Modes and File Types
For definitions of the terms used in this table see Using the Instruction Descriptions on page 82.
Parameter
Data Files
Function Files
(1)
CS - Com
m
s
IOS
-
I/O
DL
S -
D
a
ta
Log
(2
)
Address
Mode
(3)
Address Level
O
I
S
B
T,
C
, R
N
F
ST
L
MG, PD
RI/RIX
PLS
RTC
HS
C
PTO, PW
M
STI
EII
BH
I
MMI
LCD
Imm
e
diat
e
Dir
e
ct
Indir
e
ct
Bit
Wo
rd
Long W
o
rd
E
lem
en
t
Source A
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Source B
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Destination
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
(1) PTO and PWM files are only for use with MicroLogix 1100 BBB unit.
(2) The Data Log Status file can only be used for the following math instructions: ADD, SUB, MUL, DIV, NEG, and SCP.
(3) See Important note about indirect addressing.
IMPORTANT
You cannot use indirect addressing with: S, ST, MG, PD,
RTC, HSC, PTO, PWM, STI, EII, BHI, MMI, CS, IOS, and
DLS files.
efesotomasyon.com - Allen Bradley,Rockwell,plc,servo,drive