3.4 Microoperation - Shift Microoperation
3.4 Microoperation - Shift Microoperation
Shift micro-operations are used when the data is stored in registers. These micro-operations are
used for the serial transmission of data. Here, the data bits are shifted from left to right. These
micro-operations are also combined with arithmetic and logic micro-operations and data-
processing operations.
There are three types of shift micro-operations-
1. Logical Shift
2. Arithmetic Shift
3. Circular Shift
Let’s start with logical shift micro-operation.
Logical Shift
The logical shift micro-operation moves the 0 through the serial input. There are two ways to
implement the logical shift.
1. Logical Shift Left
2. Logical Shift Right
Let’s discuss both of them one by one.
To implement the logical shift left micro-operation, we use the shl symbol.
For example,
R1 ← shl R1.
This command means the 8 bits present in the R1 register will be logically shifted left, and the
result will be stored in register R1.
Moreover, the logical shift left microoperation denotes the multiplication of 2. The example
we’ve taken above when converted into decimal forms the number 10. And the result after the
logical shift operation when converted to decimal forms the number 20.
Next, we will see the logical shift right micro-operation.
To implement the logical shift right micro-operation, we use the shr symbol.
For example,
R1 ← shr R1.
This command means the 8 bits present in the R1 register will be logically shifted right, and the
result will be stored in register R1.
Logical right shift micro-operation generally denotes division by 2. The inputted bits when
converted into decimal form the number 5. And the outcome when converted into decimal forms
the number 2.
Next, we will study arithmetic shift micro-operation.
Arithmetic Shift
The arithmetic shift micro-operation moves the signed binary number either to the left or to the
right position. There are two ways to implement the arithmetic shift.
1. Arithmetic Shift Left
2. Arithmetic Shift Right
Let’s discuss both of them one by one.
R1 ← ashl R1.
This command means the 8 bits present in the R1 register will be arithmetic shifted left, and the
result will be stored in register R1.
R1 ← ashr R1.
This command means the 8 bits present in the R1 register will be arithmetic shifted right, and the
result will be stored in register R1.
Next, we will study circular shift micro-operation.
Circular Shift
The circular shift, also known as the rotate shift, moves the bits in the register's sequence around
both ends, thus ensuring no loss of information. There are two ways to implement the circular
shift.
1. Circular Shift Left
2. Circular Shift Right
Let’s discuss both of them one by one.
To implement the circular shift left micro-operation, we use the cil symbol.
For example,
R1 ← cil R1.
This command means the 8 bits present in the R1 register will be circular shifted left, and the
result will be stored in register R1.
Next, we will discuss circular shift right micro-operation.
To implement the circular shift right micro-operation, we use the cir symbol.
For example,
R1 ← cir R1.
This command means the 8 bits present in the R1 register will be circular shifted right, and the
result will be stored in register R1.
Hardware Implementation
A possible choice for a shift unit would be a bidirectional shift register with parallel load.
Information can be transferred to the register in parallel and then shifted to the right or left. In
this type of configuration, a clock pulse is needed for loading the data into the register, and
another pulse is needed to initiate the shift. In a processor unit with many registers it is more
efficient to implement the shift operation with a combinational circuit. In this way the content of
a register that has to be shifted is first placed onto a common
bus whose output is connected to the combinational shifter, and the shifted number is then loaded
back into the register. This requires only one clock pulse for loading the shifted value into the
register. A combinational circuit shifter can be constructed with multiplexers as shown in Fig.
The 4-bit shifter has four data inputs, A0 through A,, and four data outputs, H0 through H3•
There are two serial inputs, one for shift left (IL) and the other for shift right (IR). When the
selection input S = 0, the input data are shifted right (down in the diagram). When S = 1, the
input data are shifted left (up in the diagram). The function table in Fig shows which input goes
to each output after the shift. A shifter with n data inputs and outputs requires n multiplexers.
The two serial inputs can be controlled by another multiplexer to provide the three possible types
of shifts.