| UMBC | CMSC 313 -- Shift Operations Segment | Previous | Next |
The last bit shifted out is stored in the Carry Flag so that it can be tested. The form is:
To shift more than one position, you had to use the CL register:
mov CL, 4
shl AX, CL
1010 1010 1010 1010
SHR 1
0101 0101 0101 0101 => 0 in Carry Flag
0001 0010 0011 0100
SHR 4 ; Remember to use the CL register!!!
0000 0001 0010 0011 => 0 in Carry Flag ; the 0 came from bit 3
1010 1010 1010 1010
SAR 1
0101 0101 0101 0101 => 0 in Carry Flag
0001 0010 0011 0100
SAR 4 ; Remember to use the CL register!!!
0000 0001 0010 0011 => 0 in Carry Flag ; the 0 came from bit 3
1010 1010 1010 1010
ROR 1
0101 0101 0101 0101 => 0 in Carry Flag and bit 15
0001 0010 0011 0100
ROR 4 ; Remember to use the CL register!!!
0100 0001 0010 0011 => 0 in Carry Flag ; the 0 came from bit 3