5 - Arithmetic Operations 1 Outline ArithmeticOperations...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Arithmetic Operations
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Outline Arithmetic Operations overflow Unsigned addition, multiplication Signed addition, negation, multiplication Using Shift to perform power-of-2 multiply/divide Suggested reading Chap 2.3
Background image of page 2
3 Unsigned Addition • • • • • • u v + • • • u + v • • • True Sum: w +1 bits Operands: w bits Discard Carry: w bits •UAdd w ( u , v )
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Unsigned Addition Standard Addition Function Ignores carry output Implements Modular Arithmetic s  = UAddw(u , v) = (u + v)  mod 2 w
Background image of page 4
5 Signed Addition Functionality True sum requires  w+1  bits Drop off MSB Treat remaining bits as 2’s comp. integer < + + + + + + < - + = ) ( , 2 , ) ( , 2 ) , ( NegOver TMin v u v u TMax v u TMin v u PosOver v u TMax v u v u Tadd w w w w w w
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Signed Addition u v < 0 > 0 < 0 > 0 •NegOver •PosOver TAdd( u , v ) •–2 w –1 –2 w •0 •2 w –1 •2 w –1 •True Sum TAdd Result •1 000…0 •1 100…0 •0 000…0 •0 100…0 •0 111…1 •100…0 •000…0 •011…1 •PosOver •NegOver
Background image of page 6
7 Detecting Tadd Overflow Task – Given s  =  TAdd w (u , v) – Determine if s   = Add w (u , v) Claim Overflow iff either: u, v < 0, s   0 (NegOver) u, v   0, s < 0 (PosOver) ovf = (u<0 == v<0) && (u<0 != s<0); 0 2 w –1 2 w –1 •PosOver •NegOver
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Unsigned Addition Forms an Abelian Group Closed under addition – 0    UAdd w (u , v)      2 w  –1 Commutative – UAdd w (u , v) = UAdd w (v , u) Associative – UAdd w  (t, UAdd (u,v)) = UAdd w  (UAdd (t, u ), v)
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 28

5 - Arithmetic Operations 1 Outline ArithmeticOperations...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online