0% found this document useful (0 votes)
195 views5 pages

3.4 Microoperation - Shift Microoperation

Shift micro-operations are used to shift data bits within registers from left to right or right to left. There are three main types of shift micro-operations: logical, arithmetic, and circular. Logical shifts move zeros into the empty bit positions, arithmetic shifts replicate the sign bit, and circular shifts rotate bits by moving the end bit to the other end. Each type of shift can be performed left or right and are implemented using shift instructions and combinational circuits with multiplexers.

Uploaded by

Mousumi Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
195 views5 pages

3.4 Microoperation - Shift Microoperation

Shift micro-operations are used to shift data bits within registers from left to right or right to left. There are three main types of shift micro-operations: logical, arithmetic, and circular. Logical shifts move zeros into the empty bit positions, arithmetic shifts replicate the sign bit, and circular shifts rotate bits by moving the end bit to the other end. Each type of shift can be performed left or right and are implemented using shift instructions and combinational circuits with multiplexers.

Uploaded by

Mousumi Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SHIFT MICROOPERATIONS

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.

Logical Shift Left


Each bit in the register is shifted to the left one by one in this shift micro-operation. The most
significant bit (MSB) is moved outside the register, and the place of the least significant bit
(LSB) is filled with 0.
For example, in the below data, there are 8 bits 00001010. When we perform a logical shift left
on these bits, all these bits will be shifted towards the left. The MSB or the leftmost bit i.e. 0 will
be moved outside, and at the rightmost place or LSB, 0 will be inserted as shown below.

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.

Logical Shift Right


Each bit in the register is shifted to the right one by one in this shift micro-operation. The least
significant bit (LSB) is moved outside the register, and the place of the most significant bit
(MSB) is filled with 0.
For example, in the below data, there are 8 bits 00000101. When we perform a logical shift right
on these bits, all these bits will be shifted towards the right. The LSB or the rightmost bit i.e. 1
will be moved outside, and at the leftmost place or MSB, 0 will be inserted as shown below.

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.

Arithmetic Shift Left


The arithmetic shift left micro-operation is the same as the logical shift left micro-operation.
Each bit in the register is shifted to the left one by one in this shift micro-operation. The most
significant bit (MSB) is moved outside the register, and the place of the least significant bit
(LSB) is filled with 0.
For example, in the below data, there are 8 bits 00100011. When we perform the arithmetic shift
left on these bits, all these bits will be shifted towards the left. The MSB or the leftmost bit i.e. 0
will be moved outside, and at the rightmost place or LSB, 0 will be inserted as shown below.
The given binary number (00100011) represents 35 in the decimal system. And the binary
number after logical shift left (01000110) represents 70 in a decimal system. Since 35 * 2 = 70.
Therefore, we can say that the arithmetic shift left multiplies the number by 2.
To implement the arithmetic shift left micro-operation, we use the ashl symbol.
For example,

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.

Arithmetic Shift Right


Each bit in the register is shifted to the right one by one in this shift micro-operation. The least
significant bit (LSB) is moved outside the register, and the place of the most significant bit
(MSB) is filled with the previous value of MSB.
For example, in the below data, there are 8 bits 10100011. When we perform an arithmetic shift
right on these bits, all these bits will be shifted towards the right. The LSB or the rightmost bit
i.e. 1 will be moved outside, and at the leftmost place or MSB, the previous MSB value, i.e. 1,
will be inserted as shown below.

Arithmetic right shift divides the number by 2.


To implement the arithmetic shift right micro-operation, we use the ashr symbol.
For example,

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.

Circular Shift Left


Each bit in the register is shifted to the left one by one in this shift micro-operation. After
shifting, the least significant bit (LSB) place becomes empty, so it is filled with the value at the
most significant bit (MSB).
For example, in the below data, there are 8 bits 00010100. When we perform a circular shift left
on these bits, all these bits will be shifted towards the left. The MSB or the leftmost bit i.e. 0 will
be placed at the rightmost place or LSB as shown below.

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.

Circular Shift Right


Each bit in the register is shifted to the right one by one in this shift micro-operation. After
shifting, the most significant bit (MSB) place becomes empty, so it is filled with the value at the
least significant bit (LSB).
For example, in the below data, there are 8 bits 00010100. When we perform a circular shift right
on these bits, all these bits will be shifted towards the right. The LSB or the leftmost bit, i.e. 0,
will be placed at the rightmost place or MSB.

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.

You might also like