SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
The operands of a mathematical or logical operator must be well-defined expressions. That is, you must use the correct number of operands and the operation must make sense. For example, you cannot take the XOR of a floating-point value. In addition, well-defined expressions contain only symbols or assembly-time constants that have been defined before they occur in the directive's expression.
Three main factors influence the order of expression evaluation:
Parentheses | Expressions enclosed in parentheses are always evaluated first. 8 / (4 / 2) = 4, but 8 / 4 / 2 = 1 You cannot substitute braces ( { } ) or brackets ( [ ] ) for parentheses. |
Precedence groups | Operators, listed in Table 4-5, are divided into nine precedence groups. When parentheses do not
determine the order of expression evaluation, the highest precedence
operation is evaluated first. 8 + 4 / 2 = 10 (4 / 2 is evaluated first) |
Left-to-right evaluation | When
parentheses and precedence groups do not determine the order of
expression evaluation, the expressions are evaluated from left to
right, except for Group 1, which is evaluated from right to left. 8 / 4*2 = 4, but 8 / (4*2) = 1 |
Table 4-5 lists the operators that can be used in expressions, according to precedence group.
Group(1) | Operator | Description(2) |
---|---|---|
1 | + - ~ ! | Unary plus Unary minus 1s complement Logical NOT |
2 | * / % | Multiplication Division Modulo |
3 | + - | Addition Subtraction |
4 | << >> | Shift left Shift right |
5 | < <= > >= | Less than Less than or equal to Greater than Greater than or equal to |
6 | =[=] != | Equal to Not equal to |
7 | & | Bitwise AND |
8 | ^ | Bitwise exclusive OR (XOR) |
9 | | | Bitwise OR |
The assembler checks for overflow and underflow conditions when arithmetic operations are performed during assembly. It issues a warning (the "value truncated" message) whenever an overflow or underflow occurs. The assembler does not check for overflow or underflow in multiplication.