Figure 3-51 Shift and rotate instructions.

NameMnemonic and FormatDescription*
Shift logical left
SHL    OPR,CNT
Shift arithmetic left
SAL    OPR,CNT
Same as SHL
Shift logical right
SHR    OPR,CNT
Shift arithmetic right
SAR    OPR,CNT
Rotate left
ROL    OPR,CNT

LSB of result = CF
Rotate right
ROR    OPR,CNT

MSB of result = CF
Rotate left through carry
RCL    OPR,CNT
Rotate right through carry
RCR    OPR,CNT

*Number of bit positions shifted is determined by CNT

Flags: CF flag set as indicated. PF, SF, and ZF flags are set by shift instructions but left unchanged by the rotate instructions. OF flag is meaningful only if count is 1. AF flag is affected by shift instruction, but has no meaning.

Addressing modes: OPR can have any mode except immediate; CNT must be 1 or CL.

Figure 3-52 Examples of shift and rotate instructions.

Initially:
     (DL) = 10001101
     (CL) = 00000011
     (CF) = 1


Instruction                        Results

SHL    DL,CL        CF = 0        01101000
SAL    DL,CL        CF = 0        01101000
SHR    DL,CL                      00010001        CF = 1
SAR    DL,CL                      11110001        CF = 1
ROL    DL,CL        CF = 0        01101100
ROR    DL,CL                      10110001        CF = 1
RCL    DL,CL        CF = 0        01101110
RCR    DL,CL                      01110001        CF =1

Table of Contents | Next page | Previous page

This is page 40.