Freescale Semiconductor, Inc.
SC_Assem.book Page 48 Thursday, September 23, 2004 10:44 AM
Expressions
Operators
Operators
Most assembler operators pertain to both floating-point and integer values. The assembler follows these rules:
• If both operands are integers, the result is an integer value.
• If both operands are floating point values, the result is a floating-point value.
• If one operand is a floating-point value and the other operand is an integer value, the assembler converts the integer to a floating-point value, then applies the operator.
The result is a floating-point value.
Table 3.2 explains assembler operators, noting those restricted to integer operands. The main use of the relational and logical operands is with the IF conditional-assembly directive, although you can use these operands in any expression.
Table 3.2 Assembler Operators
Type
Unary
Arithmetic +
-
/
*
!
Operator Description
+
-
~
%
Plus — Returns the positive value of its operand.
Minus — Returns the negative value of its operand.
One’s Complement — Return’s the one’s complement of its integer operand; cannot be used with floating-point operands.
Logical Negate — Returns an integer 1 if the value of its operand is 0; otherwise returns a 0. The result’s memory space attribute is N
Example: If symbol BUF has the value 0, !BUF has the value 1. If BUF has the value 1000, !BUF has the value 0.
Addition — Yields the sum of its operands.
Subtraction — Yields the difference between its operands.
Multiplication — Yields the product of its operands.
Division — Yields the quotient: the first operand divided by the second. For integer operands, the result is a truncated integer.
Mod — Yields the remainder of the first operand divided by the second. (If both operands are floating-point values and the divisor is 0.0, the result is the dividend.)
48 SC100 Assembler User Guide
For More Information: www.freescale.com
Freescale Semiconductor, Inc.
SC_Assem.book Page 49 Thursday, September 23, 2004 10:44 AM
Expressions
Operators
Table 3.2 Assembler Operators ( continued)
Type
Shift
Operator Description
<<
>>
Relational <
Bitwise
|
>
<=
>=
==
!=
&
^
Shift Left — For integer operands only. Shifts and zero fills the left operand to the left; the right operand specifies the number of bits to shift.
Shift Right — For integer operands only. Shifts the left operand to the right; the right operand specifies the number of bits to shift. Extends the sign bit.
Less Than — Returns integer 1 if the expression is true, integer 0 if the expression is false. The result’s memory space attribute is N.
Example: If D = 3 and E = 5, D < E = 1.
Greater Than — Returns integer 1 if the expression is true, integer 0 if the expression is false. The result’s memory space attribute is N.
Example: If D = 3 and E = 5, D > E = 0.
Less Than or Equal — Returns integer 1 if the expression is true, integer 0 if the expression is false. The result’s memory space attribute is N.
Greater Than or Equal — Returns integer 1 if the expression is true, integer 0 if the expression is false. The result’s memory space attribute is N.
Equal — Returns integer 1 if the expression is true, integer
0 if the expression is false. The result’s memory space attribute is N.
Not Equal — Returns integer 1 if the expression is false, integer 0 if the expression is true. The result’s memory space attribute is N.
AND — For integers only. Yields the bitwise AND function of its operands.
OR — For integers only. Yields the bitwise OR function of its operands.
Exclusive OR — For integers only. Yields the bitwise exclusive OR function of its operands.
SC100 Assembler User Guide 49
For More Information: www.freescale.com