BASIC INSTRUCTION SET
3.4.2.2
ROTATE INSTRUCTIONS
Rotate instructions allow bits
in
bytes and words to be rotated. Bits rotated out of an operand are not
lost
as
in
a shift, but are "circled" back into the other "end" of the operand.
Rotates affect only the carry and overflow flags.
CF
may act
as
an extension of the operand
in
two
of
the rotate instructions, allowing a bit
to
be
isolated and then tested by a conditional jump instruction
(JC or 1NC).
CF
always contains the value of the last bit rotated out, even if the instruction does not
use this bit
as
an extension of the rotated operand.
In single-bit rotates,
OF
is
set if the operation changes the high-order (sign) bit of the destination
operand.
If
the sign bit retains its original value,
OF
is
cleared. On multibit rotates, the value of
OF
is
always undefined.
ROL
(Rotate Left) rotates the byte or
word
destination operand left by one or by the number of bits
specified
in
the count operand (an immediate value
or
the value contained
in
CL). For each rotation
specified, the high-order bit that exists from the left of the operand returns at the right
to
become the
new low-order bit of the operand.
See figure
3-9.
Example: ROL AL,
8.
Rotates the contents of AL left by 8 bits. This rotate instruction returns AL
to its original state but isolates the low-order bit
in
CF
for testing by a
1C
or
1NC
instruction.
ROR
(Rotate Right) rotates the byte or word destination operand right by one or by the number of
bits specified
in
the count operand (an immediate value or the value contained
in
CL). For each rotation
specified, the low-order bit that exits from the right of the operand returns at the left
to
become the
new
high-order bit of the operand. See figure 3-10.
1
,0
1
0
01,
,1,101,
0101,1,
01
0
1
0
1
BEFORE
ROL
ROL
shills
the bits In the memory
or
register operand to the
lell
by
the specified number
01
bit
positions.
It
copies the
bit
shilled
out
01
the
lell
01
the operand Into the right
01
the operand. The last bit
shilled
Into the least
slgnilicant
bit
01
the operand also appears In
CF. This Instruction also operates on
byte
operands.
G3010B
Figure 3-9.
ROL
3-13