Grtz Michiel
--
--
Michiel Reuser (mgjr...@cs.ruu.nl)
ROR = rotate right
the byte, word or dword bits are rotated to the right. The carry flag
gets a copy of the rightmost bit and the rightmost bit goes to the
left most bit.
ROL = rotate left
just the opposite. The left most bit (high bit) gets copied into the
carry flag.
example:
ror ax, 2
if ax = 1001 0000 1000 0010 to start, then it would be
1010 0100 0010 0000 after with a 1 in the carry flag.
Mike Schmit
-------------------------------------------------------------------
msc...@ix.netcom.com author:
408-244-6826 Pentium Processor Programming Tools
800-765-8086 ISBN: 0-12-627230-1
-------------------------------------------------------------------
ROR (rotate right) is about the same as a SHR but the least
significant bit (LSB) which is shifted out is placed into the most
significant bit. Think of it as a ring counter. I might be wrong
about this but the bit that's rotated out of the LSB also affects
the carry flag too.
ROL is exactly the same but the bit is shifted to left.
As for their uses? I can't count the number of ways, but I'd
done a lot with these two instructions. One use that comes
to mind is that if you don't want to use SHR or SHL which
will cause you to lose the value after shifting you would
usually use ROR or ROL. in their place.
> ROR (rotate right) is about the same as a SHR but the least
> significant bit (LSB) which is shifted out is placed into the most
> significant bit. Think of it as a ring counter. I might be wrong
> about this but the bit that's rotated out of the LSB also affects
> the carry flag too.
Yes, the LSB goes both to the carry flag and to the MSB.
> ROL is exactly the same but the bit is shifted to left.
There are two other instructions, RCR and RCL, that rotate a register
as if the carry flag were one more byte in the register. For example,
RCR ax,1 will take bit 0 of ax to CF, CF to bit 15 of ax and shift the
other bits in ax to the right.
--
-- Ruben (inf...@pinon.ccu.uniovi.es i693...@petra.euitio.uniovi.es)
--
> Who can explain the semantics of the instructions ROR and ROL ??
> And where are they used for ??
ror - rotate right:
-> ->
bits: 7 6 5 4 3 2 1 0
CF <-+-> X X X X X X X X ->\
| |
\-----<----------<-----/
So,
mov al,11101010b
ror al,1
makes al=01110101b
rol - rotate left:
<- <-
bits: 7 6 5 4 3 2 1 0
CF <- <- X X X X X X X X <-\
| |
\----->---------->-----/
So,
mov al,11101010b
rol al,1
makes al=11010101b
Example:
You want get bits 1 - 8 in AX, but its value must not change:
mov ax,my_val
...
ror ax,1
mov bl,al ;bits 0-7 (1-8 old)
rol ax,1 ;old value
...
-- Artem t...@telion.radio-msu.net --
-- ------------------------------------------------------- --
-- Good luck! --
ROL = ROtate Left
+-+-+-+-+-+-+-+-+
+-- | | | | | | | | | <-+
| +-+-+-+-+-+-+-+-+ |
+-----------------------+--> CF
ROL x,1 x=n bit reg
x:=(x shr (n-1))+(x shl 1)
ROR = ROtate Right
+-+-+-+-+-+-+-+-+
+-> | | | | | | | | | --+
| +-+-+-+-+-+-+-+-+ |
+-----------------------+--> CF
ROR x,1 x=n bit reg
x:=(x shl (n-1))+(x shr 1)
These instuctions simply rotate their arguments, the out-going bit goes
directly to the other side of the argument and to the carry flag.
The argument can be any general register (8,16,32bit) or memory operand,
the number of the steps can be 1, any constant or CL.
Simon, G.
fu...@balu.sch.bme.hu