Chapter
2. Assembly Language
Concepts
2-12
Arithmetic
Operators
The arithmetic operators are
as
follows:
Operator
+
*
MOD
Examples:
Meaning
Unary or binary addition
Unary or binary subtraction
Multiplication
Division. Any remainder
is
discarded (7/2=3).
Division
by
zero causes an error.
Modulo. Result
is
the remainder caused
by
a
division operation.
(7
MOD
3=1)
The following expressions generate the bit pattern for the
ASCII character
A:
5+30*2
(25/5)+30'2
5+(-30*-2)
Notice
that
the
MOD
operator must
be
separc.ted from its operands
by
spaces:
NUMBR
MOD
8
Assuming
that
NUMBR has the value 25, the previous expression evaluates to the value 1.
Shift
Operators
The shift operators are
as
follows:
Operator Meaning
y SHR x
Shift operand
'y'
to the right
'x'
bit positions.
Y SHL x
Shift operand
'y'
to the left
'x'
bit positions.
The shift operators
do
not wraparound any bits shifted
out
of the byte. Bit positions vacated
by
the shift
operation are
zero·filled. Notice that the shift operator must be separated from its operands
by
spaces.
Example:
Assume that
NUMBR
has the value 0101 0101. The effects of the shift operators
is
as
follows:
NUMBR
S,HR
2
0001 0101
NUMBR
SHL
1010 1010