Motorola dsp assembler Reference Manual



Yüklə 4,8 Kb.
Pdf görüntüsü
səhifə13/91
tarix08.10.2017
ölçüsü4,8 Kb.
#3546
1   ...   9   10   11   12   13   14   15   16   ...   91

Expressions
Operators
3-4
DSP ASSEMBLER REFERENCE MANUAL
MOTOROLA
.6
(floating point)
2.7e2
(floating point)
A constant may be written without a leading radix indicator if the input radix is changed
using the RADIX directive. For example, a hexadecimal constant may be written without
the leading dollar sign ($) if the input radix is set to16 (assuming an initial radix of 10). The
default radix is10. See Chapter 6 on the RADIX directive for more information.
3.5.2
  String Constants
String constants that are used in expressions are converted to a concatenated sequence
of ASCII bytes (right aligned), as shown below.  Strings used in expressions are limited to
the long word size of the target processor; subsequent characters in the string are ig-
nored.  Null strings (strings that have no characters) have a value of 0.
String constants greater than the maximum number of characters can be used in expres-
sions, but the Assembler will truncate the value and will use only those characters that will
fit in a DSP long word. In this case, a warning will be printed. This restriction also applies
to string constants using the string concatenation operator. Handling of string constants
by the DC and DCB directives is an exception to this rule; see Chapter 6 for a description.
Examples:
'ABCD'
($41424344)
'''79'
($00273739)
'A'
($00000041)
''
($00000000) - null string
'abcdef'
($61626364)
'abc'++'de'
($61626364)
3.6
  OPERATORS
Some of the Assembler operators can be used with both floating point and integer values.
If one of the operands of the operator has a floating point value and the other has an in-
teger value, the integer will be converted to a floating point value before the operator is
applied and the result will be floating point.  If both operands of the operator are integers,
the result will be an integer value.  Similarly, if both the operands are floating point, the
result will be a floating point value.
3.6.1
  Unary operators
plus
(+)
minus
(-)
one’s complement
(~)
- Integer only
logical negate
(!)


Expressions
Operators
MOTOROLA
DSP ASSEMBLER REFERENCE MANUAL
3-5
The unary plus operator returns the value of its operand.
The unary minus operator returns the negative of its operand.
The one’s complement operator returns the one’s complement of its operand.  It cannot
be used with a floating point operand.
The unary logical negation operator returns an integer 1 (memory space attribute None)
if the value of its operand is 0 and will return a 0 otherwise. For example, if the symbol
BUF had a value of 0, then !BUF would have a value of 1. If BUF had a value of 1000,
!BUF would have a value of 0.
3.6.2
  Arithmetic operators
addition
(+)
subtraction
(-)
multiplication
(*)
division
(/)
mod
(%)
The addition operator yields the sum of its operands.
The subtraction operator yields the difference of its operands.
The multiplication operator yields the product of its operands.
The divide operator yields the quotient of the division of the first operand by the second.
For integer operands the divide operation will produce a truncated integer result.
The mod operator applied to integers will yield the remainder from the division of the first
operand by the second.  If the mod operator is used with floating point operands, the mod
operator will apply the following rules:
Y % Z = Y
if Z = 0
= X
if Z <> 0
where X has the same sign as Y, is less than Z, and satisfies the relationship:
Y = i * Z + X
where i is an integer.
3.6.3
  Shift operators
shift left
(<<)
- Integer only
shift right
(>>)
- Integer only


Expressions
Operators
3-6
DSP ASSEMBLER REFERENCE MANUAL
MOTOROLA
The shift left operator causes the left operand to be shifted to the left (and zero-filled) by
the number of bits specified by the right operand.
The shift right operator causes the left operand to be shifted to the right by the number of
bits specified by the right operand.  The sign bit will be extended.
Shift operators cannot be applied to floating point operands.
3.6.4
  Relational operators
less than
(<)
less than or equal
(<=)
greater than
(>)
greater than or equal
(>=)
equal
(==)
not equal
(!=)
Relational operators all work the same way.  If the indicated condition is true, the result of
the expression is an integer 1.  If it is false, the result of the expression is an integer 0.  In
either case, the memory space attribute of the result is None.
For example, if D has a value of 3 and E has a value of 5, then the result of the expression
D<E is 1, and the result of the expression D>E is 0.  Each operand of the conditional op-
erators can be either floating point or integer.  Test for equality involving floating point val-
ues should be used with caution, since rounding error could cause unexpected results.
Relational operators are primarily intended for use with the conditional assembly IF direc-
tive, but can be used in any expression.
3.6.5
  Bitwise operators
AND
(&)
- Integer only
OR
(|)
- Integer only
exclusive OR
(^)
- Integer only
The bitwise AND operator yields the bitwise AND function of its operands.
The bitwise OR operator yields the bitwise OR function of its operands.
The bitwise exclusive OR operator yields the bitwise exclusive OR  function of its oper-
ands.
Bitwise operators cannot be applied to floating point operands.


Yüklə 4,8 Kb.

Dostları ilə paylaş:
1   ...   9   10   11   12   13   14   15   16   ...   91




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə