Assembler Guide
Expressions
Expressions are evaluated at assembly time, not at run time. Any of the operators shown below may be used on constants to generate a new constant. Precedence is the same as for normal arithmetic, but
parentheses can be used to group expressions to ensure the expected order of
evaluation. All operands are treated as 32 bit integers. Floating point constants, Quad
or Oct constants may not be manipulated by operators.
Operators
| Unary Operators |
| Operator |
Meaning |
Example |
Value left in r0 |
| - |
negate |
movl #-1, r0 |
-1 |
| ~ |
bit negate |
movl #~0xFFFFFFFE, r0 |
0x1 |
| Binary Operators |
| Operator |
Meaning |
Example |
Value left in r0 |
| & |
bitwise and |
movl #0xFFFF & 07, r0 |
7 |
| | |
bitwise or |
movl #01 | 05, r0 |
5 |
| ^ |
bitwise exclusive or |
movl #07 ^ 05, r0 |
2 |
| ! |
operand1 | ~operand2 |
movl #01 ! 05, r0 |
0xFFFFFFFB |
| * |
multiplication |
movl #12 * 7, r0 |
84 |
| / |
integer division |
movl #75 / 6, r0 |
12 |
| %
| modulo |
movl #75 % 6, r0 |
3 |
| + |
addition |
movl #7 + 4, r0 |
11 |
| - |
subtraction |
movl #7 - 4, r0 |
3 |
| >> |
logical right shift |
movl #8 >> 2, r0 |
2 |
| << |
logical left shift |
movl #1 << 4, r0 |
16 |