Assembly: Bit Rotating

Posted June 15, 2006 by William_Wilson in Computer programming

This tutorial describes shifting bits left or right by a desired number of places with a wrap around to the other side.


This method saves all bits.
For instance, if you shifted AX by eight, in either direction, the new AX value would hold AH as the old AL. AL would become the old AH. This is done with a temporary copy of the register which is then shifted into the blank slots as the shift occurs.

Shift left (in this case, by eight):

shld AX,8

Shift right (in this case, by eight):

shrd AX,8

You simply provide the two operands:
1) the register to shift
2) the number of places to shift

Questions/Comments: [email protected]
-William. ยง (marvin_gohan)

The Conversation

Follow the reactions below and share your own thoughts.