Sie sind auf Seite 1von 49

Topics

Introduction
Data Types
Number Systems
Complements
Data representation(codes)
Fixed-Point Representation
Floating-Point Representation
Other Binary codes
Arithmetic Operations
Floating-point Arithmetic Operations
 Why study computer organization and architecture?
◦ Design better programs, including system software such as
compilers, operating systems, and device drivers.

◦ Optimize program behavior.


◦ Able to peoperly configure a computer system using the available
sub systems

◦ Evaluate (benchmark) computer system performance.

◦ Able to select “proper” computer systems for a particular


environment (cost and effectiveness)

 Is there any difference between computer Architecture and


Organization?
2
 Computer organization
◦ Organization refers to operational units and their interconnections
that realize the architectural specifications.
◦ Encompasses all physical aspects of computer systems and
concerned with the way the hardware components are connected
together to form a computer system.
 Attributes: hardware details transparent to programmers
◦ Control signals
◦ Computer/peripheral interface
◦ Memory technology
◦ How does a computer work?

3
 Computer architecture
◦ is concerned with the structure and behavior of the various
functional modules of the computer and how they interact to
provide the processing needs of the user.
◦ Logical aspects of system implementation as seen by the
designer.
 Therefore, computer architecture refers to
◦ Attributes of a system visible to programmers
◦ Attributes that have a direct impact on the execution of
programs
 Attributes
◦ Instruction set and formats
◦ Data representation & data types
◦ I/O mechanisms
◦ Addressing techniques
◦ How do I design a computer?
4
 Example: Cont’d…..

 IBM, SUN and Intel ISAs, it is possible to purchase


processors which execute the same instructions from
more than one manufacturer
 All these processors may have quite different internal
organizations but they all appear identical to a
programmer, because their instruction sets are the
same
 Organization & Architecture enables a family of computer
models
◦ Same Architecture, but with differences in Organization
◦ Different price and performance characteristics
 When technology changes, only organization changes
◦ This gives code compatibility (backwards)

5
 What is data type in programming?
• It is the classification of a particular type of
information in to different types.

 What is data type in digital computer?


•The data types found in the registers of digital computer
may be classified as one of the following categories:-
1. Numbers used in arithmetic computations.
2. Letters of the alphabet used in data
processing, and
3. Other discrete symbols used for specific
purpose.
• All the types of data except binary numbers are
represented as binary coded form in register.
• This is because registers are made up of flip-flop
 What is flip-flop?
• Flip-flops are a binary cell or a two state device that
stores only binary numbers(0’s and 1’s)

 Everything a computer does is broken down into a


series of 0s and 1s
 Number systems are organized ways to represent
numbers
 A number system of base ,or radix ‘r’ is a system
that uses a distinct symbols for r digits.

 Binary- base(2) 0,1


 Octal- base(8) 0-7
 Decimal – base(10) 0-9
 Hexadecimal- base(16) 0-9,A,B,C,D,E,F

 Each number in one system has a


corresponding number in another.
 It referred to as base 2 numbering system
 Used to represent every piece of data stored in a
computer: all of the numbers, letters, and instructions

128 64 32 16 8 4 2 1
2x64 2x32 2x16 2x8 2x4 2x2 2x1
Binary 0 1 0 1 1 0 0 1

Base 0+ 64 0+ 16 8+ 0+ 0+ 1 = 89
10
+ +

01011001 = 89
Binary Base 10
 Conversion from Decimal to Binary, octal
&Hexadecimal
1. (37)(10) = ………(2)
2. (15.75)(10) = ………(2)
3. (37)(10) = ………(8)
4. (15.75)(10) = ………(8)
5. (37)(10) = ………(16)
6. (15.75)(10) = ………(16)

 Conversion from Binary to Decimal


1. 1001001)(2)= ……..(10)
2. (11001.11)(2)= ……..(10)
 Conversion from octal & Hexadecimal to
Binary
1. (457)(8)= ……..(2)
2. (34.25)(8)= ……..(2)
3. (3AF.5)(16)= ……..(2)
4. (A0C)(16)= ……..(2)
 Complements are used in digital computers for simplifying
the subtraction operation and logical manipulation.

 There are two types of complements for each base ‘r’


systems.
 (r-1)’s complement
 r’s complement

 For r bases (2 and 10) i.e. binary and decimal


 1’s complement
 2’s complement binary

 9’s complement
 10’s complement decimal
The (r-1)’s complement
 For any number N in base r with number of digits n, the
(r-1)’s complement is :(rn -1)-N
Example1: for decimal number with n=4,
The 10n is represented by 1 followed by n 0’s

104 = 10000 and 104 -1= 9999


The 9’s complement is obtained by subtracting each digit
from 9.
The 9’s complement of 47635 is 99999-47634= 52364
 For binary number r=2 and r-1 =1,the 1’s complement for N
is :
 is represented by binary number 1 followed by
n 0’s
Example2: for n=4, and

 The 1’s complement is found by subtracting each digit from 1.


 1’s complement is performed by changing 1’s to 0’s and 0’s to 1’s.

 1’s complement of 11oo11 is 001100, for 0100110 is


1011001
 The (r-1)’s complement of octal and hexadecimal is obtained by
subtracting each digit from 7 or F(15) respectively.
(r’s) complement
The r’s complement of an n-digit number N in base r is :

where N ≠ 0 and 0 for N=0


It also obtained by adding 1 to (r-1)’s complement. So

Or since is a number represented by 1 followed by


n 0’s , the r’s complement of the number can be obtained
by leaving all least significant 0’s unchanged , subtracting
the first nonzero least significant digit from r(r=10) and
subtracting all higher significant digits from 9.
Example: the 10’s complement of 547600 is:

Leave the two 0’s unchanged and subtract 6 from 10 and


subtract the reaming from 9.

Ans. 452400
 2’s complement
 Can be obtained by leaving all least significant 0’s and
the first 1 unchanged, and change 1’s to 0 and 0’s to 1
Example: the 2’s complement of 10110100 is
01001100
The complement of complement is the
number it self :
Subtracting of Unsigned Numbers
 The subtraction of two n-digit unsigned numbers M-N
where (N≠0) in base r can be done as follows:
1. Add the minuend M to the r’s complement of the
subtrahend N.
2. If M ≥N, the sum will produce an end carry which is
discarded and what is left is the result of M-N
3. If M<N, the sum doesn’t produce an end carry, and is
equal to which is the r’s complement of (M-
N). Or take the r’s complement of the sum and add
negative sign at the front.
 Example1: 72532-13250=……… ,here M > N. so it
produce an end carry,
M=72532
10’s complement of N= +86750
sum =159282
discard an end carry =100000
answer =59282
Example2:13250-72532=………., M<N.
M=13250
10’s complement of N= +27468
sum=40718, no end carry
Answer negative 59282 = 10’s complement of 40718
 When we subtracting in complements the negative answer
is recognized by absence of end carry and complemented
result.
 Subtraction of binary numbers (X - Y) by following the
above method. Here X=1010100 Y=1000011
 X= 1010100
 2’s complement of Y= +0111101
 sum = 10010001
 Discard end carry = -10000000
 answer X – Y = 0010001
 For Y – X, Y= 1000011
 2’s complement of X= +0101100
 sum= 1101111, no end carry
 Answer is negative 0010001 = 2’s complement of 1101111
 The same rules in(r-1)’s complements. The only difference is that
when an end carry is generated, it is not discarded but added to
the least significant digit of the result.

 Example: in (r-1)’s complement (M-N)=M+( )


Subtract (76425 – 28321) using 9’s complements.
9’s complement of 28321 is 71678

 76425 subtract (11010011 – 10001100) using


 +71678 1’s complement.
 148103 1’s complement of 10001100 is 01110011
 1  11010011
 48104  +01110011
 101000110
 1
 101000111
Fixed point Representation
 Positive integers, including zero, can be represented as unsigned
numbers. However, to represent negative integers, we need a
notation for negative values
 In ordinary arithmetic, a negative number is indicated by minus
sign and a positive number by a plus sign. But in computer
system we use 0’s and 1’s.
 In addition the number may have binary(decimal)point. It’s
position represents fractions, integers or both.
 The representation of binary point in the register is
characterized by position.
 Two ways of specifying position: fixed point and floating point
 Fixed point, the binary point is always fixed in one position.
 We mostly used this two positions for
1. a binary point at extreme left of the register to make the
stored number fraction
2. Extreme right of the register to make the stored number
integer.
Integer Representation
When the integer binary number is positive the sign is
represented by ‘0’ and negative by’1.

1. Representation of Negative numbers


◦ There are different ways of representing negative numbers in a
computer.
a) Sign- magnitude Representation
b) One’s complement Representation
c) Two’s Complement Representation
 In signed binary representation, the left-most bit is used to
indicate the sign of the number.
 Traditionally, 0 is used to denote a positive number and 1 is
used to denote a negative number.
 Example 1: Represent -13 using 5-bits sign magnitude
representation
- first we convert 13 to binary i. e 01101
Now -13 = 11101
 Example 2: Represent –24 using 8-bits sign magnitude
representation
24=…………….
-24=……………
 Addition is the same as ordinary arithmetic
 In one’s complement representation, all positive integers are
represented in their correct binary format. The difference lies
in the representation of negative numbers.
 Each 0 is transformed into 1 and each 1 into 0.

Example 1. Represent –3 using One’s complement


representation with word size 4
3 = 0011
-3=1100
Example 2: Add –7 and 3 with word size 8
- 7 is 11111000
+ 3 is 00000011
the sum is ( 11111011)
Example2. Add -4 and +6 with word size 8
- 4 is 11111011
+ 6 is 00000110
the sum is (1) 00000001 the one in the parenthesis is the
external carry.
 In two’s complement representation, positive numbers
are represented, as usual, in singed binary, just like in
one’s complement. The difference lies in the
representation of negative numbers.
 A negative number represented in two’s complement is
obtained by first computing the one’s complemented
and then add one.
 Ex1. : -3 is represented in binary as 00000011
Its one’s complement representation is
11111100.
The two’s complement is obtained by adding
one. It is 11111101.
 Ex2. Let’s try subtraction (the subtraction is
performed by adding the two’s complement).
(3) 00000011
(-5) + 11111011
11111110 - The result is correct

 Ex3 Add +4 and -3 (the subtraction is performed


by adding the two’s complement).
+4 is 00000100
-3 is 111111101
 The result is [1] 000000001 -If we ignore the
external carry the result is 00000001 ( i. e 1 In
decimal). This is the correct result.
 The floating-point representation of a number has
two parts.
The first part represents a signed, fixed-point
number called the mantissa.
The second part designates the position of
the decimal (or binary) point and is called the
exponent
 Floating-point is always interpreted to represent a
number in the following form:- m x re.
m- Mantissa.
e -Exponent.
r- Radix.
 The exponent indicates the actual position of the decimal(binary) point
to the right.
 Example: The decimal number + 4132.689 is represented in floating-
point with a fraction and an exponent as follows:
 + 4132.689 = +0. 4132689 x 10+4
Number Fraction Exponent
+ 4132.689 = +0.4132689 +04
4132689- Mantissa.
4 -Exponent.
10- Radix.
 Example 3, the Binary number + 1101.01 is represented with an 8-bit
fraction and 6-bit exponent as follows:
 + 1101.01 = + 0.110101 x 2+4
Number Fraction Exponent
+ 1101.01 = + 0.11010100 +000100
11010100- Mantissa.
000100 -Exponent.
2- Radix.
 In the computer these numbers are represented by

 The Exponent is represented by a biased exponent, which is


expressed as:-
Biased Exponent = True Exponent + 2N -1
Where:
 Biased Exponent is characteristics of the true exponent.

 N is the number of bits representing the exponent.

 For example, Convert to normalized binary floating point


form using 7-bit exponent and 16-bit mantissa
a) 8.5 b) – 16.25
Solution for question a) 8.5
 First Convert 8.5 in to Binary

(8.5)(10) = (8)(10) + (0.5)(10)


(8.5)(10) = (1000)(2) + (0.1)(2) = (1000.1)(2)
 1000.1 is normalized in to + 0.10001 x 2+4

Mantissa = 10001
Exponent = 4
Biased Exponent = True Exponent + 2N -1
= 4 + 27 -1
= 22 + 26
= 100 + 1000000 = 1000100
0 1000100 1000100000000000
Solution for question b) -16.25
 In previous sections we introduced the most common types
of binary-coded data found in digital computers.
 Other binary codes for decimal numbers and alphanumeric
characters are sometimes used.
 Digital Computers also employ other binary codes for special
applications.
 BCD (Binary Coded Decimal
 EBCDIC (Extended Binary Coded Decimal Interchange
Code )
 ASCII (American Standard Code for Information
Interchange)
 There are two types of BCD coding techniques used before.
a) 4 bits BCD and
b) 6 bits BCD
BCD (4 -bits)
 The 4 bit BCD, which represent any digit of decimal number
by four bits of binary numbers.
 If you want to represent 219 using 4 bit BCD you have to say
0010 0001 1001

BCD(6-bit)
 It uses 6-bits to code a Character (2 for zone bit and 4 for
digit bit)
 It can represent 26 = 64 characters (10 digits, 26 capital
characters and some other special characters).
 Some Coding Examples
Character zone zone (2 Bit) Digit (4 Bit)
0-9 0 0-9
A-I 3 1-9
J-R 2 1-9
S-Z 1 2-9
Example 1. Represent Character A using 6-bits BCD
A 11 0001
A = 110001
 It is an 8-bit coding scheme: (00000000 – 11111111)
 It accommodates to code 28 or 256 different characters
 It is a standard coding scheme for the large computers.
 Coding Example:
Character zone (4 Bit) Digit (4 Bit)
0-9 15 0-9
a-i 8 1-9
j-r 9 1-9
s-z 10 2-9
A-I 12 1-9
J-R 13 1-9
S-Z 14 2-9
Example 1. Represent Character A using EBCIDIC
A 1100 0001
A= 1100001
 Used widely before the introduction of ASCII-8 (the Extended
ASCII)
 Uses 7 bits to represent a character;
 With the seven bits, 27(or 128) different characters can be
coded (0000000-1111111)
 Coding examples:
Character zone (3 bit) digit (4 bit)
0-9 3 0-9
A-O 4 1-15
P-Z 5 0-10
a- o 6 1-15
p- z 7 0-10
Example 1. Represent Character A using ASCII
A 100 0001
A= 1000001
 Since computers can understand binary numbers, they
perform arithmetic operations using binary numbers.
 the four binary computations are:
1. Binary Addition
2. Binary Subtraction
3. Binary Multiplication
4. Binary Division
Binary Addition
 The binary addition rules may be written as follows:
 0+0=0
 0+1=1
 1+0=1
 1+1=0 plus a carry of 1 into the next position
 1+1+1=1 plus a carry of 1 into the next position
 Example1. 6+7 =13
110 ----> 6
+ 111 ----> 7
…… ---->13
 Example2. 19+31+10=60

10011------->19
+ 11111------->31
+ 1010------->10
……… ------>60
Binary Subtraction
 It operates by the same rule as decimal subtraction. The rule is
as follows;
 0-0=0
 1-0=1
 1-1=0
 10-1=1
 Example1.
11100 28 101101 45
- 11010 -26 - 111 -7
…….… = 2 ……… = 38
Hardware Implementation Algorithms

a .signed magnitude
b.2’s complement
Binary Multiplication
 It is a very simple process that operates by the following obvious
rulers:
(a) Multiplying any number by 1 rules the multiplicand unchanged
 0x1=0 ,1x1=1
(b) Multiplying any number by 0 produces 0
 0x0=0 ,1x0=0
Hardware implementation algorithm
 The product of two n-bit numbers requires 2n bits to contain
all possible values.
 Example: 6 x-5=-30, First, the precision is extended from 4
bits to 8(2 x4). Then the numbers are multiplied, discarding
the bits beyond 8.
 00000110 (6)
 × 11111011 (-5)
 =========
 110
 1100
 00000
 110000
 1100000
 11000000
 110000000
 1100000000
 ==========
 1111100010 (-30)
Binary Division
 That is, the process for dividing one binary
number (the dividend) by another (the divisor)
is based on the rules for binary subtraction
and multiplication and Similar to decimal
division.
 Example1.
1111 ÷ 101 = …….
 Example2.
1111101 ÷ 11001 = ……
 Arithmetic operations with floating numbers are more
complicated and its execution takes more time and require more
complex hardware.
 Adding or Subtracting, requires first alignment of the radix point
since the exponent must be equal before add/subtract the mantissa.
 Example: add the following
0.5372400 x 102 and 0.1580000 x 10-1
 First the exponents should be equal
0.5372400 x 102
+ 0.0001580 x 102
========================

0.5373980 x 102
 when two normalized mantissas added, the sum may create
overflow. But this can be normalized by shifting the sum to the right
and increase the exponent.
 When we subtract, the result may have zeros to the most
significant digits.
 Example 0.56870 x 105
 -0.56580 x 105
 =======
 0.00290 x 105
 This number has 0 in its most significant digit, which creates
underflow. So to normalize this shift the mantissa to the left
and decrease the exponent.
 The algorithm has four parts

1. Check for zeros


2. Align the mantissa
3. Add or subtract the mantissa
4. Normalize the result
 Multiplication : no comparison of exponent and alignment of
mantissa.
1. Check for zeros
2. Add the exponents
3. Multiply the mantissa Can be done parallel
4. Normalize the product
 No overflow
 Division: division of two floating point numbers need
subtraction of exponents and division of mantissas.
1. Check for zeros
2. Initialize the register and evaluate the sign
3. Align the dividend
4. Subtract the exponent
5. Divided the mantissa
 To perform decimal arithmetic in computer, which is capable of
perform decimal arithmetic the data should be store in a binary
coded form.
 What is decimal arithmetic unit?
It is a digital function that performs arithmetic microoperations.
This unit accepts coded decimal numbers. Each digit is represented
by four bit in the code.(commonly 4 bit BCD)
 This 4 bit BCD is taken as unit during decimal microoperations.

 Arithmetic operation in decimal number is the same as binary

arithmetic.
Addition and Subtraction with BCD
 For adding two numbers in BCD we use BCD adder ,this is a
circuit that adds two BCD digits in parallel and produces a
sum digit also in BCD.
 In BCD, there cannot exist a value greater than 9 (1001) per
bite. To correct this, 6 (0110) is added to that sum to get the
correct first two digits:
 Example: 9 + 8 = 17
 1001 + 1000 =10001, when we represent in 4-bit BCD
,0001 0001 which is not correct, since the result is greater
than 9. we must add 6(0110).
 10001 + 0110 = 10111, that gives the correct result, then in
BCD 0001 0111, which correspond to the digits ‘1’ and ‘7’.
 Subtraction is done by adding the ten's complement of
the subtrahend. To represent the sign of a number in BCD,
the number 0000 is used to represent a positive number, and
1001 is used to represent a negative number.
 Example: 357 − 432
 In signed BCD, 357 is 0000 0011 0101 0111.to represent the
negative 432, we use 10’s complement. So, 999 − 432 =
567, and 567 + 1 = 568.
 −568 in signed BCD is 1001 0101 0110 1000, when we add
 0000 0011 0101 0111 + 1001 0101 0110 1000 = 1001 1000 1011 1111
 0 3 5 7 + 9 5 6 8= 9 8 11 15
 Some of the results are invalid .so add 6 to correct it.
 1001 1000 1011 1111 + 0000 0000 0110 0110 = 1001 1001 0010 0101
 9 8 11 15 0 0 6 6 9 9 2 5 (-925)
 The 10’s complement of the result is 1000 − 925 =75,the answer is -75.
 Multiplication :we are assuming four digit numbers and
each digit represented with four bit. There are 3 registers
with 3 sign flip-flops. This are A,B,Q As, Bs and Qs.
 Register A and B have more four bits designated by Ae,Be that
provide an extension of one more digits to the registers.

 The BCD arithmetic unit adds the two five digits in parallel
and place it in five-digit register A. the end-carry goes to
flip-flop E
 The purpose of digit Ae is to accommodate overflow while
adding the multiplicand to the partial product during
multiplication. Be to form 9’s complement of the devisor when
subtracted from the partial reminder during division
operation.
 Division: it is similar to binary division. At this time the carry
in E determines the relative magnitude of the two
numbers(A,B).if E=0,A < B. if E=1 ,A ≥ B.

Das könnte Ihnen auch gefallen