Module - 2
Module - 2
Organization
Course Code CSE2003
Octal
Fixed Point
Instructions
Numerical Decimal
Information
Floating Point
Data Hexa
Non Numeric Decimal
Recap Exercise
FF and AB ( hexadecimal number system )
F X B = ? ()16 = () 8 = ()10 = () 2
The hardware that does arithmetic on sign magnitude integers is not fast, and it is
more complex than the hardware that does arithmetic on 1's comp. and 2's comp.
integers.
Use 1 bit of integer to represent the sign of the integer
let sign bit of 0 be positive, 1 be negative.
The rest of the integer is a magnitude, using same encoding as unsigned
integers Signed numbers, on the other hand, require an
example: 4 bits arithmetic sign. The most significant bit of a
0101 is 5 binary number is used to represent the sign bit.
1101 is -5 If the sign bit is equal to zero, the signed binary
number is positive; otherwise, it is negative.
To get the additive inverse of a number, just flip (not, invert, complement,
negate) the sign bit.
Sign Magnitude
• The most significant bit (MSB) represents the sign.
• A 1 in the MSB bit position denotes a negative number; a 0
denotes a positive number.
• The remaining n 1 bits are preserved and represent the magnitude
of the number.
• The following examples illustrate the sign–magnitude
representation:
Things to Notice:
Because of the sign bit, there are 2 representations for 0.This is a problem for
hardware. . .
0000 is 0, 1000 is 0
The computer must do all calculations such that they come out correctly and
the same whichever representation is used.
One's Complement
historically important, and we use this representation to get 2's complement
integers.
Now, nobody builds machines that are based on 1's comp. integers.
In the past, early computers built by Semour Cray (while at CDC) were
based on 1's comp. integers.
EXAMPLES: 11100
This must be a negative number.
To find out which, find the additive inverse!
00011 is +3 by sight,
so 11100 must be -3
Things to notice:
1. any negative number will have a 1 in the MSB.
2. there are 2 representations for 0,
00000 and 11111.
Two's Complement
• In the two’s-complement method, the negative numbers are
inverted and augmented by one.
• The MSB is the sign bit.
• The positive numbers are similar to those of the sign–magnitude
method.
• The following examples illustrate the one’s-complement
representation:
the negative values are all "slid" down by one, eliminating the extra zero
representation
how to get an integer in 2's comp. representation:
positive values are the same as for sign/mag and 1's comp.
They will have a 0 in the MSB (but it is NOT a sign bit!) positive:
just write down the value as before negative:
Data Representations
Unsigned
Signed Magnitude
1’s Complement
2’s Complement
Assignment
• Submit a Case Study report on “ Calculator
Arithmetic Using Binary Coded Decimal”
• Ref: Vincent .P. Heuring, Harry F. Jordan “ Computer
System design and Architecture” Pearson, 2nd Edition,
2003
Lecture : Addition & Subtraction
Re-Cap
1. Tell, how many number unsigned numbers can be generated
from 4 bits.
2. Specify the common issue in signed numbers and I’s
complement representation
3. State a reason why modern computers are using 2’s
complement representation for their arithmetic operations
examples:
0100 0001 is 41 (hex) or 65 (decimal). It represents `A'
0100 0010 is 42 (hex) or 66 (decimal). It represents `B'
Algorithm: character string integer
0+0=0
1+0=1
a 0011
+b +0 0 0 1
sum 0100
Unsigned vs. Signed Addition
Hardware is identical for result bits all between unsigned and signed
adder.
Difference in the is only detection of overflows, that is of results which
cannot be represented in the given format
1 1 0 0 1 0 0 1 20110
1 1 0 0 1 0 0 0 20010
1 1 0 0 1 0 0 0 1 40110
Addition Using the One’s-Complement
Method
This method uses the simplicity of one’s complement in representing the
negative of a number.
The process of addition using the one’s-complement method may be simple
or complicated, depending on the numbers being used.
In certain cases, an additional correction may need to be carried out to arrive
at the correct answer.
The following examples illustrate one’s-complement additions for four cases
000010102 1210
+000000102 + 410
000011002 1610
Negative Addition Example
-1210 + -410 = -1610
111101002 -1210
+111111002 + -410
111100002 -1610
000100002
+111111002
000011002
01102 610
+00112 +310
10012 -710 not good!
Underflow Example
• Assume 4-bit restriction and 2’s complement
• Minimum possible value: -(24-1) = -8
10112 -510
+10112 +-510
01102 610 not good!
Exercise based on overflow/underflow
• Add the following using 2’s complement
representation in 8-bit register. Also check
overflow/underflow
i. -27 + (-101)
ii. +45 + (-65)
iii. +27 + 101
iv. -103 +(-69)
Character representation
Addition
Subtraction
Over flow/Under flow
Assignment
• Submit a Case Study report on “ Calculator
Arithmetic Using Binary Coded Decimal”
• Ref: Vincent .P. Heuring, Harry F. Jordan “ Computer
System design and Architecture” Pearson, 2nd Edition,
2003
References
Text Book
• M. M. Mano, Computer System Architecture,
Prentice-Hall,2004
Lecture : Binary Multiplication
Re-Cap
• Session Objectives
• To provide knowledge on character representations
• To teach procedure for addition and subtraction
• To provide knowledge on differences between
overflow/underflow
• Teaching Learning Material
• LCD, White board Marker, Presentation slides
Multiplication
0x0=0
0x1=0
1x0=0
1x1=1
Multiply (unsigned)
When LSB of Q is 0 only Shift, otherwise A <- A + M and then Shift Right CAQ
Computer Architecture and Organization (CSE-
76
2003)
Multiplying Negative Numbers
Sign extension is
shown in blue For a negative multiplier, a
straightforward solution is to form the 2’s-
complement of both the multiplier and the
10011 (-13) multiplicand and proceed as in the case
Multiplicand M of a positive multiplier.
X 01011 (+11)
Multiplier Q This is possible because
complementation of both operands does
------------------------------------------------- not change the value or the sign of the
1111110011 product.
111110011
00000000 A technique that works equally well for
1110011 both negative and positive multipliers –
000000 Booth algorithm.
--------------------------------------------------
1 1 0 1 1 1 0 0 0 1 (-143) Product P
Multiplication
Serial Multiplier flow chart
Example 11 x 13
Examples
Assignment
• Show that 7x3 =3x7 using Unsigned serial
multiplier algorithm
Lecture : Binary Multiplication-Booth’s
Algorithm
Objectives & Teaching Learning Material
• Session Objectives
• To provide knowledge on Signed multiplications
• To teach procedure for binary multiplication using Booth’s
Algorithm
• To solve the problems on Booth’s multiplication
• Teaching Learning Material
• LCD, White board Marker, Presentation slides
Re-Cap
1. What is the name of unsigned multiplication algorithm
Multiplication
Booth’s flow chart
Example 7 x 3
Examples
Programming Assignment
• Develop a Simulator to perform multiplication
operation two signed number and display the step
by step result.
Lecture : 2’s Complement Division
Re-Cap
• Session Objectives
• To provide knowledge on Signed multiplications
• To teach procedure for binary multiplication using Booth’s
Algorithm
• To solve the problems on Booth’s multiplication
• Teaching Learning Material
• LCD, White board Marker, Presentation slides
Division of Unsigned Binary Integers
1. Load the divisor into the M register and the dividend into the A , Q registers. The
Dividend must be expressed as a 2n- bit two's compliment numbers. Several
examples of this approch are shown in following example.
2. Shift A, Q left 1 bit position.
3. If M and A have the same signs , Perform AA-M ; oterwise ,A A+M.
4. The above operation is successful if the sign of A is the same before and after
the operation.
a) If the operation is successful or (A=0 AND Q= 0) ,then Set Q0 1
b) If the operation is unsuccessful and (A!=0 or Q!=0),then Q00 and restore
the privious value of A.
5. Repeat steps 2 through 4 as many as there are bit positions in Q.
6. The reminder is in A. If ht e signs if the divisor and dividend were the same,
Then the quotient is in Q; Otherwise, the correct quotient is the two's
complement of Q.
-7/ 3
A Q Action
1111 1001 Initial Value
1111 0010 Shift
0010 Add
1111 0010 Restore
1110 0100 Shift
0001 Add
1110 0100 Restore
1100 1000 Shift
1111 Add
1111 1001 Set Q0 =1
1111 0010 Shift
0010 Add
1111 0010 Restore
Examples
• Divide the following using 2’s Complement
Division Algorithm
7 / -3
-7 / 3
-7 /-3
11 / 13
-11 / 13
11 / -13
-11 / -13
Summary
Unsigned Division
Introduction to Unsigned division algorithm
Flow Chart
Interpretation of an example to flowchart
Sample problems & Solutions
Programming Assignment
• Develop a Simulator to perform Division algorithm
using 2’s complement division algorithms display
the step by step result.
Lecture: Floating Point Numbers
Re-Cap
1. Distinguish between Binary multiplication and division in the
perspective of implementation
2. In Binary Division, If A>0 then what would be the next step ?
• Session Objectives
• To teach the difference between fixed point and floating
point
• To provide knowledge on various floating point
representations
• To introduce the terms for the various parts floating point
representation
Fraction Exponent
+0.6132789 +04
For example:
Binary number +1001.11
Fraction(8 bits) Exponent (6 bits)
01001110 000100
0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 1 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4.3100 × 104
Add/Subtract Rule
1.Choose the number with the smaller exponent and shift its mantissa right a number of
steps equal to the difference in exponents.
2.Set the exponent of the result equal to the larger exponent.
3.Perform addition/subtraction on the mantissas and determine the sign of the result.
4.Normalize the resulting value, if necessary.
FP Addition & Subtraction Flowchart
FP Addition & Subtraction Flowchart
Introduction
Floating point Representation
Examples
Normalization
IEEE formats
Floating point Arithmetic
Floating point Addition & Subtraction
Floating point Multiplication & Division
References
Text Book
• William Stallings “Computer Organization and
architecture” Prentice Hall, 7th edition, 2006
References
Text Book
• M. M. Mano, Computer System Architecture,
Prentice-Hall,2004