The following tutorial describes how to shift bits left or right by a desired number of places, with a wrap-around to the other side through the carry flag.
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, and AL would become the old AH.
This method is a more precise way as it does not involve a copy, in most cases. Instead, it uses the carry bit to rotate the bits.
To shift left (in this case by eight):
To shift right (in this case by eight):
You simply provide the two operands:
1) the register to shift
2) the number of places to shift
*NOTE: With this method, if the shift is one, the overflow flag will be set and thus an error. If the shift is more than one, then flag becomes undefined and will be assumed false.
Questions/Comments: [email protected]
-William. § (marvin_gohan)