KEMBAR78
Unit II.1 Computer Arithmetic Intro | PDF | Computer Architecture | Theory Of Computation
0% found this document useful (0 votes)
6 views14 pages

Unit II.1 Computer Arithmetic Intro

The document provides an overview of computer arithmetic, focusing on the Arithmetic and Logic Unit (ALU) and its role in executing instructions and performing calculations. It discusses integer representation, including signed numbers using Sign-Magnitude and Two's Complement methods, along with their benefits and limitations. Additionally, it covers the range of numbers representable in different bit formats and references relevant literature on computer organization and architecture.
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)
6 views14 pages

Unit II.1 Computer Arithmetic Intro

The document provides an overview of computer arithmetic, focusing on the Arithmetic and Logic Unit (ALU) and its role in executing instructions and performing calculations. It discusses integer representation, including signed numbers using Sign-Magnitude and Two's Complement methods, along with their benefits and limitations. Additionally, it covers the range of numbers representable in different bit formats and references relevant literature on computer organization and architecture.
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/ 14

Sanjivani Rural Education Society’s

Sanjivani College of Engineering, Kopargaon-423 603


(An Autonomous Institute, Affiliated to Savitribai Phule Pune University, Pune)
NACC ‘A’ Grade Accredited, ISO 9001:2015 Certified

Department of Computer Engineering


(NBA Accredited)

Subject- Computer Organization & Architecture


Unit 2 – Computer Arithmetic
Introduction

Dr. D. B. Kshirsagar, Professor & Head


E-mail : hodcompcoe@sanjivani.org.in
Contact No: 02434 – 222862 Ext :141, 9890472165
Arithmetic & Logic Unit
• Plays role in Execution phase of instructions
• Does the calculations
• Performs arithmetic and logical operations
• Handles integers
• May handle floating point (real) numbers
• May be separate FPU (math co-processor)
• May be on chip separate FPU (486DX +)

21-09-2021 Computer Organization: Arithmetic 2


ALU Inputs and Outputs

21-09-2021 Computer Organization: Arithmetic 3


Integer Representation
• Only have 0 & 1 to represent everything
• Positive numbers stored in binary
• e.g. 41=00101001
• No minus sign
• No period
• How to represent signed numbers ?
• Sign-Magnitude
• Two’s compliment
• How to represent floating point numbers ?
• floating point number representation formats (Binary form with different
fields – IEEE 754 standards)

21-09-2021 Computer Organization: Arithmetic 4


Sign-Magnitude

• Left most bit (MSB) is sign bit


• 0 means positive
• 1 means negative Sign Magnitude
• +18 = 00010010 0 1… n-1
• -18 = 10010010 000 111
• Problems
• Need to consider both sign and magnitude in arithmetic
• Two representations of zero (+0 and -0)
000 001 010 011 100 101 110 111 -3 to +3

21-09-2021 Computer Organization: Arithmetic 5


Two’s Complement
• 2’s Complement = 1’s complement + 1 (Binary addition)
0 + 0 = 00
• +3 = 00000011 (8 bit format) 0 + 1 = 01
• +2 = 00000010 1 + 0 = 01
1 + 1 = 10
• +1 = 00000001
• +0 = 00000000
• -1 = 11111111 0000 0001 1111 1110 + 1 = 1111 1111
• -2 = 11111110
• -3 = 11111101 000 001 010 011 100 101 110 111
• Represent 1 and -1 with 2 bit, 4 bit, 6 bit and 8 bit format
• What is the number represented by 2’s complement form - 11, 1111, 11111111

21-09-2021 Computer Organization: Arithmetic 6


Benefits

• One representation of zero


• Arithmetic works easily
• Negating is fairly easy
• 3 = 00000011
• Boolean complement gives 11111100
• Add 1 to LSB 11111101

21-09-2021 Computer Organization: Arithmetic 7


Exercise
• Represent signed 3-bit and 4-bit numbers using both forms.
Signed Magnitude 2’s Complement Signed Magnitude 2’s Complement
000 (0) 000 0 0000 (0) 0000
001 (1) 001 1 0001 (1) 0001
010 (2) 010 2 0010 Range -
011 (3) 011 3 0011
• 3 bit nos
-4 to +3
100 (-0) 100 -4 0100
• 4 bit nos
101 (-1) 101 -3 0101 -8 to +7
110 (-2) 110 -2 0110 • n bits ?
111 (-3) 111 -1 0111 (7) 0111
1000 (-0) 1000 -8
1001 1001 -7
1010 1010 -6

1111 -7 1111 -1

DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 8


Geometric Depiction of Two’s Complement Integers

n=4 n=5
-8 to +7 -16 to +15

21-09-2021 Computer Organization: Arithmetic 9


Negation Special Case 1

• 0= 00000000
• Bitwise not 11111111
• Add 1 to LSB +1
• Result 1 00000000
• Overflow is ignored, so:
•-0=0

21-09-2021 Computer Organization: Arithmetic 10


Negation Special Case 2
• -128 = 10000000
• bitwise not 01111111
• 2’s Complement of –ve number gives same
• Add 1 to LSB +1 +ve number
• Result 10000000 • What could be the range of n bit numbers
represented using 2’s complement form ?
• So -(-128) = -128 X • e.g. Range of 3 bit and 4 bit numbers ?
• Monitor MSB (sign bit) • In both forms, -ve nos are having 1 at MSB

• It should change during negation


• Means 8 bits are not sufficient to represent -128 OR + 128
• So take 9 bits
• + 128 = 010000000
• -128 = 110000000 OR 10000000 (8 or 9 bits ?)
• With 8 bit range is -128 to +127
21-09-2021 Computer Organization: Arithmetic 11
Range of Numbers

• 8 bit 2’s complement


• +127 = 01111111 = 27 -1
• -128 = 10000000 = -27
• 16 bit 2’s complement
• +32767 = 011111111 11111111 = 215 - 1
• -32768 = 100000000 00000000 = -215

21-09-2021 Computer Organization: Arithmetic 12


Conversion Between Lengths (Sign Extension)

• Positive number pack with leading zeros


• +18 = 00010010
• +18 = 00000000 00010010
• Negative numbers pack with leading ones
• -18 = 10010010
• -18 = 11111111 10010010
• i.e. pack with MSB (sign bit)

21-09-2021 Computer Organization: Arithmetic 13


Book References
• William Stallings, Computer Organization and Architecture: Designing
for performance, Pearson Education/ Prentice Hall of India, 10th
Edition

• Zaky S, Hamacher, Computer Organization, 5th Edition, McGraw-Hill


Publications, 5th Edition

• John P Hays, Computer Architecture and Organization, McGraw-Hill


Publication, 3rd Edition.

• A. Tannenbaum, Structured Computer Organization, Prentice Hall of


India 4th Edition

21-09-2021 Computer Organization: Introduction 14

You might also like