Number Systems and Circuits for Addition - PowerPoint PPT Presentation

About This Presentation
Title:

Number Systems and Circuits for Addition

Description:

... ( 90) = 10 Six Flags over the PC Intel x86 Status Register Intel x86 Flags The Eflags Program Intel x86 Condition Codes Intel x86 Puzzler Explain why the ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 19
Provided by: Preferred99
Learn more at: https://people.hsc.edu
Category:

less

Transcript and Presenter's Notes

Title: Number Systems and Circuits for Addition


1
Number Systems and Circuits for Addition
Integer Overflow
  • Lecture 8
  • Section 1.5
  • Tue, Jan 30, 2007

2
Addition of Signed Integers
  • Express negative numbers in twos complement
    form.
  • Add, using the ordinary rules of addition.
  • Pay special attention to two bits
  • The carry-in bit of the last column.
  • The carry-out bit of the last column.

3
Subtraction of Signed Integers
  • Express negative numbers in twos complement
    form.
  • Then take the twos complement of the subtrahend.
  • Add, using the ordinary rules of addition.
  • Pay special attention to two bits
  • The carry-in bit of the last column.
  • The carry-out bit of the last column.

4
Addition of Signed Integers
  • Eight cases

a b a b c-in c-out Valid
P P P 0 0 yes
P P N 1 0 no
P N P 1 1 yes
P N N 0 0 yes
N P P 1 1 yes
N P N 0 0 yes
N N P 0 1 no
N N N 1 1 yes
5
Integer Overflow
  • If the result is too large to fit in the allotted
    space, the condition is called overflow.
  • Integer overflow occurs when
  • The sum of two positive integers is too large.
  • The sum of two negative integers is too large.

6
Addition of Signed Integers
  • How do we detect overflow?

a b a b c-in c-out Valid
P P P 0 0 yes
P P N 1 0 no
P N P 1 1 yes
P N N 0 0 yes
N P P 1 1 yes
N P N 0 0 yes
N N P 0 1 no
N N N 1 1 yes
7
Addition of Signed Integers
  • How do we detect overflow?

a b a b c-in c-out Valid
P P P 0 0 yes
P P N 1 0 no
P N P 1 1 yes
P N N 0 0 yes
N P P 1 1 yes
N P N 0 0 yes
N N P 0 1 no
N N N 1 1 yes
8
Integer Overflow
  • Integer overflow is detected when the carry-in
    bit does not match the carry-out bit in the
    high-order position.

9
Case P P ? N An Example
  • 80 90 01010000 01011010
  • 10101010
  • 01010110
  • 86
  • 80 90 256 86

10
Case N N ? P An Example
  • (80) (90) 10110000 10100110
  • 01010110
  • 86
  • (80) (90) 256 86

11
Case P N ? P An Example
  • 90 (80) 01011010 10110000
  • 00001010
  • 10
  • 90 (80) 10

12
Case P N ? N An Example
  • 80 (90) 01010000 10100110
  • 11110110
  • 00001010
  • 10
  • 80 (90) 10

13
Six Flags over the PC
14
Intel x86 Status Register
15
Intel x86 Flags
a b a b CF SF OF
100 200 300 0 0 0
231-1 1 -231 0 1 1
200 -100 100 1 0 0
100 -200 -100 0 1 0
-100 200 100 1 0 0
-200 100 -100 0 1 0
-231 -1 231-1 1 0 1
-100 -200 -300 1 1 0
16
The Eflags Program
17
Intel x86 Condition Codes
18
Intel x86 Puzzler
  • Explain why the combinations
  • CF 1, SF 1, OF 1
  • CF 0, SF 0, OF 1
  • never occur.
Write a Comment
User Comments (0)
About PowerShow.com