5 Arithmetic for Computers PART1

download 5 Arithmetic for Computers PART1

of 12

Transcript of 5 Arithmetic for Computers PART1

  • 8/17/2019 5 Arithmetic for Computers PART1

    1/12

    Lecture 5

  • 8/17/2019 5 Arithmetic for Computers PART1

    2/12

    Page  2 2

    Binary Number System

     In any number base, the value of ith

     digit d is, d x Basei

    where i starts at 0 & increases from right to left

     For eg, 1011 ! "1x#$ % "0x$ % "1x1$ % "1x0$ ! 1110

    I'S word is # bits long, hence we can re(resent #)bit (atterns

     *east Significant Bit "*SB$ + efers to the rightmost bit "bit 0$

    ost Significant Bit "SB$ + efers to the leftmost bit "bit #1$

  • 8/17/2019 5 Arithmetic for Computers PART1

    3/12

    Page  3 3

    -ddition & Subtraction

    .g 1/ 10 % 10 230000 0111 ! 10

      + 230000 0110 ! 10

      230000 1101 ! 1#10

     .g / 10 ) 10 

    230000 0111 ! 10

      ) 231111 1010 ! )10 

    230000 0001 ! 110

  • 8/17/2019 5 Arithmetic for Computers PART1

    4/12

    Page  4 4

    ulti(lication

     ulti(ly 1000  by 1001 

    First o(erand, 1000 + ulti(licand

     Second o(erand, 1001+ ulti(lier 

     'roduct + 1001000

     For an n)bit multi(licand & m)bit multi(lier, (roduct is 4 m%n bits

  • 8/17/2019 5 Arithmetic for Computers PART1

    5/12

    Page  5 5

    ulti(lication 5ardware

  • 8/17/2019 5 Arithmetic for Computers PART1

    6/12

    Page  6 6

    ulti(lication -lgorithm

  • 8/17/2019 5 Arithmetic for Computers PART1

    7/12

    Page  7 7

    efined 6ersion of ulti(lication 5ardware

  • 8/17/2019 5 Arithmetic for Computers PART1

    8/12

    Page  8 8

    ulti(lication -lgorithm

  • 8/17/2019 5 Arithmetic for Computers PART1

    9/12

    Page  9 9

    ulti(lication in I'S

     I'S has two #)bit registers to contain the 7)bit (roduct/ 5i& *o

     

    I'S instructions for multi(lication/ mult "multi(ly$ & multu

    "multi(ly unsigned$

    8 mult 9s, 9s# : 'laces 7)bit (roduct in 5i*o

     

    ;o move the (roduct to general (ur(ose registers I'S uses twoinstructions/ mflo "move from *o$ & mfhi "move from 5i$

    8 mfhi 9s1 :9s1 ! 5i

  • 8/17/2019 5 Arithmetic for Computers PART1

    10/12

    Page  10 10

  • 8/17/2019 5 Arithmetic for Computers PART1

    11/12

    Page  11 11

  • 8/17/2019 5 Arithmetic for Computers PART1

    12/12

    Page  12 12