pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

Comparing Addresses (page 77)
Constant Expressions (page 81)
Conditional Expressions (page 81)
Special Expressions (page 85)
Bit Operations (page 92)
Data Types of Expressions
The result of an expression can be any data type or address type except STRING or UNSIGNED.
The compiler determines the data type of the result from the data type of the operands in the
expression. All operands in an expression must have the same data type, with the following
exceptions:
An INT expression can include STRING, INT, and UNSIGNED(1-16) operands. The system
treats STRING and UNSIGNED(1-16) operands as if they were 16-bit values. That is, the
system:
Puts a STRING operand in the right byte of a 16-bit word and sets the left byte to 0, with
no sign extension.
Puts an UNSIGNED(1-16) operand in the right bits of a 16-bit word and sets the unused
left bits to 0, with no sign extension. For example, for an UNSIGNED(2) operand, the
system fills the 14 leftmost bits of the word with zeros.
An INT(32) expression can include INT(32) and UNSIGNED(17-31) operands. The system
treats UNSIGNED(17-31) operands as if they were 32-bit values. The system places an
UNSIGNED(17-31) operand in the right bits of a doubleword and sets the unused left bits to
0, with no sign extension. For example, for an UNSIGNED(29) operand, the system fills the
three leftmost bits of the doubleword with zeros.
In all other cases, if the data types do not match, use the type transfer functions described in
Chapter 15 (page 274).
Operator Precedence
Operators in expressions can be arithmetic (signed, unsigned, or logical) or conditional (relational,
signed or unsigned). Within an expression, the compiler evaluates the operators in the order of
precedence. Within each level of precedence, the compiler evaluates the operators from left to
right.
Table 23 Precedence of Operators
PrecedenceOperationOperator
0 (highest)Signed left bit shift<<
Signed right bit shift>>
Unsigned left bit shift'<<'
Unsigned right bit shift'>>'
1Indexing[n ]
Address of identifier@
Unary plus+
Unary minus-
2Bit extraction<...>
3Signed multiplication*
70 Expressions