Shift micro-operations are used for the serial transfer of data and also support in conjunction with arithmetic, logic, and several data-processing operations. The contents of a register can be shifted to the left or the right.
Simultaneously, that the bits are shifted, the first flip-flop holds its binary data from the serial input. In shift-left operation, the serial input transfers a bit into the rightmost position. In shift-right operation, the serial input transfers a bit into the leftmost position. The data transferred by the serial input decides the type of shift.
There are three types of shift micro-operations are as follows −
It transfers 0 by the serial input. The symbol "shl" can be used for logical shift left and "shr" can be used for logical shift right.
R1 ←R1 shl R1
R2 ←R1 shr R2
The register symbol should be the equivalent on both sides of the arrows.
This circulates or pivots the bits of register around the two ends without any trouble of data or contents. In circular shift, the serial output of the shift register is linked to its serial input. "cil" and "cir" is used for circular shift left and right respectively. The symbolic documentation for the shift micro-operations is demonstrated in the table.
|R ←R1 shl R||Shift-left register R|
|R ←R1 shr R||Shift-right register R|
|R ←R1 cil R||Circular shift-left register R|
|R ←R1 cir R||Circular shift-right register R|
|R ←R1 ashl R||Arithmetic shift-left R|
|R ←R1 ashr R||Arithmetic shift-right R|
This shifts a signed binary number to left or right. An arithmetic shift left multiplies a signed binary number by 2 and shift left divides the number by 2. Arithmetic shift micro-operation leaves the sign bit constant due to the signed number remains equal when it is multiplied or divided by 2.
Arithmetic Shift Right
The leftmost bit in a register influences the sign bit, and the remaining bits influence the number. The sign bit is 0 for positive and 1 for negative. Negative numbers are in 2's complement form. The figure displays a symbolic register of n bits.
Bit Rn-1 in the leftmost position holds the sign bit.
Rn-2 is the most significant bit of the number and
R0 is the least significant bit. The arithmetic shift-right leaves the sign bit constant and shifts the number (involving the sign bit) to the right. Therefore
Rn-1 remains the equal,
Rn-2 receives the bit from
Rn-1 and so on for the other bits in the register. The bit in
R0 is lost.