In contrast to unary operators, binary operators specify
actions to be performed on two terms or expressions. You can
enclose expressions in angle brackets to specify the order of
evaluation.
Table 4 Summary of Binary Operators
BinaryOperator
OperatName ExampleOperation
+ Plus sign A+B Addition
- Minus sign A-B Subtraction
* Asterisk A*B Multiplication
/ Slash A/B Division
@ At sign A@B Arithmetic shift
& Ampersand A&B Logical AND (product)
! Exclamation A!B Logical OR (sum)
point
\ Backslash A\B Logical XOR (difference)
All binary operators have equal priority. You can group terms or
expressions for evaluation by enclosing them in angle brackets.
The enclosed terms and expressions are evaluated first, and
remaining operations are performed from left to right. For
example:
.LONG 1+2*3 ; Equals 9
.LONG 1+<2*3> ; Equals 7
Note that a 64-bit result is returned from all binary operations.
If you use the 64-bit result in a context requiring less than
64 bits, only the lower-order bits of the result are used. If
the truncation causes a loss of significance in a data-storage
directive, the assembler displays an error message.
The following sections describe the arithmetic shift, logical
AND, logical inclusive OR, and logical exclusive OR operators.
1 – Arithmetic Shift Operator
Use the arithmetic shift operator (@) to perform left and right
arithmetic shifts of arithmetic quantities. The first argument
is shifted left or right by the number of bit positions that
you specify in the second argument. If the second argument is
positive, the first argument is shifted left and the low-order
bits are set to zero. If the second argument is negative, the
first argument is shifted right and the high-order bits are set
to the value of the original high-order bit (the sign bit). For
example:
.LONG ^B101@4 ; Yields 1010000 (binary)
.LONG 1@2 ; Yields 100 (binary)
A = 4
.LONG 1@A ; Yields 10000 (binary)
.LONG ^X1234@-A ; Yields 123(hex)
2 – Logical AND Operator
The logical AND operator (&) takes the logical AND of two
operands. For example:
A = ^B1010
B = ^B1100
.LONG A&B ; Yields 1000 (binary)
3 – Logical Inclusive OR Operator
The logical inclusive OR operator (!) takes the logical
inclusive OR of two operands. For example:
A = ^B1010
B = ^B1100
.LONG A!B ; Yields 1110 (binary)
4 – Logical Exclusive OR Operator
The logical exclusive OR operator (\) takes the logical
exclusive OR of two arguments. For example:
A = ^B1010
B = ^B1100
.LONG A\B ; Yields 0110 (binary)