The Shifting Operations - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

The Shifting Operations

Description:

Left Shift Logical / Open Left Shift. Right Shift Logical / Open Right Shift. ... Rotate Left / Closed Shift Left thro Carry. Rotate Right / Closed Shift Right thro. ... – PowerPoint PPT presentation

Number of Views:80
Avg rating:3.0/5.0
Slides: 13
Provided by: psd1
Category:

less

Transcript and Presenter's Notes

Title: The Shifting Operations


1
The Shifting Operations
  • Left Shift Logical / Open Left Shift.
  • Right Shift Logical / Open Right Shift.
  • Right Shift Arithmetic.
  • Rotate Left / Closed Shift Left thro Carry.
  • Rotate Right / Closed Shift Right thro. Carry.

2
The Open Left Shift Operation
LSHIFT gt Open ( Logically) left shift
Operand a by 1 bit.
cnPresent ? a ((i-1) Prev. for i
1..(n-1) n7/15/31 CARRY/BORROW Flag
Present?a(n-1)Prev. i..e. Prev.
CARRY/BORROW is

OVERWRITTEN.
c0Present? 0 Affects ZERO SIGN Flags too,
Does not affect OVERFLOW Flag
a(n-1) a(n-2) a(i) a(i-1)
a(0)
c(n-1) c(n-2) c(i1) c(i) c(i-1)
c(1) c(0)
CY Flag
0
3
The Open Right Shift Operation
RSHIFT L gtOpen / Logically Right Shift
Operand a by 1 bit
cnPresent ? a(i1) Prev. for i 0..(n-2)
n7/15/31 CARRY/BORROW Flag Present?
a(0)Prev. i..e. Prev. CARRY/BORROW

is OVERWRITTEN
c(n-1)Present? 0 Affects ZERO SIGN
Flags too, Does not affect OVERFLOW Flag
a(n-1) a(i1) b(i)
a(2) a(1) a(0)
c(n-1) c(n-2) c(i) c(i-1)
c(1) c(0)
CY Flag
0
4
The Arithmetic Right Shift Operation
ARSHIFT gt Right Shifted Arithmetic Operand
a. Where ciPresent ? a(i1)Prev. for i
0..(n-2) n7/15/31 CARRY/BORROW Flag
Present? a0Prev. i.e. Prev. CARRY/BORROW

is OVERWRITTEN.
c(n-1)Present? a(n-1)Prev. . Sign is
Preserved in its designated Position.
Affects ZERO Flag too, does not affect OVERFLOW
SIGN Flags.
a(n-1) a(i1) a(i)
a(2) a(1) a(0)
c(n-1) c(n-2) c(i) c(i-1)
c(1) c(0)
CY Flag
5
The Rotate Left ( Closed Left Shift) Operation
RAL gt CLOSED Left Shift Operand a through
Carry once where CARRY/BORROW Flag Present ?
a(n-1) Prev. c(i) Present ? a(i-1)
Prev. for i 1..(n-1) n7/ 15/31 c0
Present ? CARRY/BORROW Flag Prev.Cy_In i.e.
CARRY/BORROW is Preserved in the LSBit.
Affects CARRY/BORROW, ZERO SIGN Flags only,
does not affect OVERFLOW Flag.
a(n-1) a(n-2) a(i) a(i-1)
a(1) a(0)
c(n-1) c(i1) c(i)
c(2) c(1) c(0)
CY Flag
6
The Rotate Right ( Closed Right Shift) Operation
RAR CLOSE Right Shift Operand a thro. Carry
Where CARRY/BORROW Flag Present? a0 Prev.
c(i)Present ? a(i1) Prev. for i
0..(n-2) n7/15/31 c(n-1) Present ?
CARRY/BORROW Flag Prev.Cy_In. i.e .
CARRY/BORROW is Preserved in the MSBit.
Affects CARRY/BORROW, ZERO SIGN Flags only,
does not affect OVERFLOW Flag.
a(n-1) a(i1) a(i)
a(2) a(1) a(0)
c(n-1) c(n-2) c(i) c(i-1)
c(1) c(0)
CY Flag
7
The Shifting Operations Table
  • Sl. No. Operation
    ALU Function
    Code
  • 1. Open/ Logical Left Shift

    1 X 0 0 0
  • 2. Closed Left Shift / Rotate Left

    1 X 0 0 1
  • 3. Arithmetic Right Shift

    1 X 1 0 0
  • 4. Open Right Shift

    1 X 0 1 0

  • 5. Closed Right Shift / Rotate Right
    1
    X 0 1 1

8
The Shifter bit Selection Table
  • Sl. No. Operation Key ALU
    Function Code Cy c(n-1) c(i) c(0)

  • ( S2 S1 S0 )
  • 1. Open/ Logical Left Shift
    0 0 0 a(n-1) a(n-2)
    a(i-1) 0
  • --------------------------------------------------
    --------------------------------------------------
    ---------------
  • 2. Closed Left Shift / Rotate Left
    0 0 1 a(n-1) a(n-2)
    a(i-1) Prev.Cy
  • ---------------------------------------------
    --------------------------------------------------
    ----------------
  • 3. Arithmetic Right Shift
    1 0 0 a(0)
    a(n-1) a(i1) a(1)
  • --------------------------------------------------
    --------------------------------------------------
    ---------------
  • 4. Open Right Shift
    0 1 0 a(0)
    0 a(i1) a(1)
  • --------------------------------------------------
    --------------------------------------------------
    ---------------
  • 5. Closed Right Shift / Rotate Right
    0 1 1 a(0) Prev. Cy
    a(i1) a(1)
  • --------------------------------------------------
    --------------------------------------------------
    ----------------

9
The Carry Generator Structure

a(0)
a(n-1)
a(0)
a(0)
Cy
I4 I3 I2 I1 I0
S2
5 1 MUX
S1
S0
Shifted O/P To Cy
10
The MSB Generator Structure

0
a(n-1)
a(n-2)
Cy
a(0)
I4 I3 I2 I1 I0
S2
5 1 MUX
S1
S0
Shifted O/P To C(n-1)
11
The Intermediate Bits Generator Structure

a(i1)
a(i-1)
a(i-1)
a(i1)
a(i1)
I4 I3 I2 I1 I0
S2
5 1 MUX
S1
S0
Shifted O/P To C(n-2) .. C (1)
12
The LSB Generator Structure

a(1)
a(1)
0
Cy
a(1)
I4 I3 I2 I1 I0
S2
5 1 MUX
S1
S0
Shifted O/P To C(0)
Write a Comment
User Comments (0)
About PowerShow.com