Chapter 8. Structured Text (ST) Programming
366
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
GFK-2950C
8.1.3
Operators
The table below lists the operators that you can use within an expression. They are listed according
to their evaluation precedence, which determines the sequence in which they are executed within
the expression. The operator with the highest precedence is applied first, followed by the operator
with the next highest precedence. Operators of equal precedence are evaluated left to right.
Operators in the same group, for e and -, have the same precedence.
Any address operators used in LD can be used on ST operands. Address operators have precedence
over the ST language operators. Address operators include indirect addressing (for example, @Var1),
array indexing (for example, Var1[3]), bit within word addressing (for example, Var1.X[3]), and
structure fields (for example, Var1.field1).
Precedence
Operator Operand Types
Description
Group 1 (Highest)
(…)
Parenthesized
expression
Group 2
-
INT, DINT, REAL, LREAL
Negation
NOT
BOOL, BYTE, WORD, DWORD
Boolean complement
Group 3
**,^
INT, DINT, UINT, REAL, LREAL
8
Exponentiation
9, 10
Group 4
*
INT, DINT, UINT, REAL, LREAL
Multiplication
/
INT, DINT, UINT, REAL, LREAL
Division
9, 11
MOD
INT, DINT, UINT
Modulus operation
Group 5
+
INT, DINT, UINT, REAL, LREAL
Addition
-
INT, UINT, DINT, REAL, LREAL
Subtraction
Group 6
<, >, <=,
>=
INT, DINT, UINT, REAL, LREAL, BYTE, WORD,
DWORD
Comparison
Group 7
=
ANY
12
Equality
<>, !=
Inequality
Group 8
AND, &
BOOL, BYTE, WORD, DWORD
Boolean AND
Group 9
XOR
BOOL, BYTE, WORD, DWORD
Boolean exclusive OR
Group 10 (Lowest) OR
BOOL, BYTE, WORD, DWORD
Boolean OR
Some comparison and math operators have corresponding built-in functions. For instance,
the ‘+’
operator is similar to the ADD_INT function. You can use either the language operator or the built-in
function. The built-in function has the advantage of returning an ENO status. For additional
information refer to
Built-in Functions Supported for ST Calls
Operand Types
Type casting is not supported. To convert a type, use one of the built-in conversion functions. Use of
built-in functions is described in
For untyped operators (+, *, …), the types of the operands must match.
8
The base must be type REAL or LREAL. If the base is REAL, the power can be type INT, DINT, UINT, or REAL and the result is
type REAL. If the base is type LREAL, the power must be LREAL and the result will be LREAL
9
Use of math operators can cause
results are truncated.
10
If either operand is positive or negative infinity, the result is undefined.
11
The CPU flags a “divide
-by-
0” error as an application fault.
12
Operators that can take operands of type ANY can be used with any of the supported elementary data types. The
supported data types are: BOOL, INT, DINT, UINT, BYTE, WORD, DWORD, LREAL and REAL. STRING and TIME data types
are not supported
Summary of Contents for PACSystems RX7i
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451...