[go: up one dir, main page]

0% found this document useful (0 votes)
10 views18 pages

Computer Organization Lecture I-2

The document provides an overview of computer organization, focusing on how computers process data using binary and decimal number systems. It explains the conversion between these systems, the representation of positive and negative numbers, and the arithmetic operations involved, including ones and twos complement methods. Key concepts such as sign bits, overflow bits, and the implications of polarity in binary arithmetic are also discussed.

Uploaded by

brianrylee384
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views18 pages

Computer Organization Lecture I-2

The document provides an overview of computer organization, focusing on how computers process data using binary and decimal number systems. It explains the conversion between these systems, the representation of positive and negative numbers, and the arithmetic operations involved, including ones and twos complement methods. Key concepts such as sign bits, overflow bits, and the implications of polarity in binary arithmetic are also discussed.

Uploaded by

brianrylee384
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Computer Organization

Lecture I
Presented by Tandoh Lawrence (PhD)
Computers and data
• Computers are required to accept, process, and output different forms of data
• Numbers:
• integers
• real
• Images
• Audio e.t.c
• However, they only understand 0’s and 1’s
• Hence, all data is converted to 0’s and 1’s and stored/processed in this
manner
• Processing of this data is limited to simple arithmetic, logical, and Boolean
operations
The decimal number system
• Unlike computers, we are used to the decimal number system
• A number in the decimal number system is represented with 10
digits
• 0,1,2,3,4,5,6,7,8, and 9
• Any number in the decimal number system can be represented with
the aid of these digits and powers of 10
• For example: 3567 can be represented as
• (3x103)+(5x102)+(6x101)+(3x100)
• Note how powers of 10 are used since we are dealing with the
decimal system
The decimal number system
• In this system there will be a total of numbers where n denotes the total number of
digit positions
• The values in the decimal number system range from 0 to 10n -1 where n denotes
the total number of digit positions
• The maximum value is (10n - 1) if we include 0
• This system caters for both positive and negative values denoted by a preceding “+”
and “-” symbols respectively
• Since the “+” and “-” signs are symbols we do not generally consider them to
occupy digit positions
• Note that since we are using signs, our range doubles when we include polarity i.e -
10n -1 and 10n -1
• Henceforth when talking about range, we do not consider the zero value
The binary number system
• As stated earlier, computers only understand 0’s and 1’s and hence cannot
use the decimal number system which is made up of 10 different digits
• The binary number system that only uses two symbols (0 and 1) to
represent all of its values is best for this job
• Any number in the binary system can be represented with the aid of these
digits and powers of 2
• For example 1011 can be represented as
• [(1x23)+(0x22)+(1x21)+(1x20)]Base2
• [8 + 0 + 2 + 1] Base2
• Converting each of the decimal values above into binary yields:
• 1000 + 0000 + 0010 + 0001 = 1011
The binary number system
• There will be a total of numbers in this system
• The binary/decimal value equivalents in this system will range from 0
to 2n - 1 (range)
• The maximum binary/decimal value equivalent in this system will be
2n – 1 if we include 0
• Please note that the actual numeric representation of values for the
above two points will differ depending on the system being used
• Interesting observation: computing the result in terms of the decimal
system without converting to the base of 2 gives us the decimal
equivalent of the binary value
Decimal to binary conversion
• But in order to obtain full functionality we also need to be able to convert
from decimal to binary as well
• To do that continuously divide the decimal number by 2 whilst keeping track
of the result and the reminder
• Do this until the dividend becomes 0
• For example: convert 11 to binary
11
2 5 1
2 2 1
2 1 0
2 0 1

• Read the result upwards: 1011


Adding polarity I
• As we observed, the decimal systems makes provisions for both
positive and negative numbers using symbols/signs
• How do we implement this in binary taking into consideration that
computers only know ones and zeros and do not accept signs?
• This is achieved by adding an extra sign bit in the most significant bit
(MSB) position
• The binary number is:
• Negative when the bit is 1
• Positive when the bit is 0
Adding polarity I
• Note that including polarity in a system that is limited to a specific
number of bits will require that the MSB be converted to the sign bit
• This reduces the actual number of available value bits by 1
• Problem 1:
• Hence, instead of doubling, our range halves to -2 N-1 - 1 and 2N-1 – 1 due to
the conversion of the bit in the MSB position to a sign bit (note that once
again, we do not consider 0)
• Problem 2:
• Note that there are two zeros in this signed system
• 0000 (positive zero)
• 1000 (negative zero)
Adding polarity II -4 10100
-3 10011
• Addition in the binary number system is pretty straight -2 10010
forward
• How about subtraction? -1 10001
• Lets try to answer the question posed above by adding +2 to - -0 10000
1 which should result in 1
+0 00000
00010
10001 +1 00001
10011
• But 10011 is -3 and hence addition between positive and +2 00010
negative numbers does not work at all times in this system +3 00011
• What is the solution?
+4 00100
Ones complement I
-4 11011
• Ones complement uses the same principle of adding a sign bit to -3 11100
implement polarity
-2 11101
• However in ones complement, every negative value is the
inversion of the bits in the positive value -1 11110
• Inversion refers to replacing zero bits with one bits and vice versa -0 11111
• Range for this system is the same as that for the previous signed
system: -2N-1 - 1 and 2N-1 – 1 (where N is the total number of bit +0 00000
positions allowed by the system) +1 00001
• Signed additions and subtractions are possible in ones
complement if rules are followed +2 00010
• The special cases and their rules are discussed in the slides that +3 00011
follow
+4 00100
Ones complement II
• First of all you need to note the following
• The original numbers given in all examples to be considered represent their
normal (positive) binary equivalent with a sign indicating their polarity
• An over flow bit refers to obtaining an extra bit of value 1 which is supposed
to precede the most significant bit (MSB) during the addition of two binary
numbers
• When we add or subtract in ones complement, an over flow bit of one
indicates that the result is positive (this does not include the case of adding
two negative numbers)
• Over flow bits are added to the LSB
• In the absence of a carry bit, the result is negative
Ones complement arithmetic
• There are three cases to consider in all
• Case-1: Addition of positive and negative number when positive number has greater magnitude
(simple subtraction):
• take 1’s complement of negative number to obtain its negative ones complement equivalent and add the sign
bit
• add the two numbers
• the end-around carry of the sum is added to the least significant bit (LSB)
• the second sum is the final result
• Case-2: Addition of positive and negative number when negative number has greater magnitude:
• take 1’s complement of negative number and add the sign bit
• add the two numbers together
• there will not be any end-around carry bit in this case since the result is sure to be negative
• however, the result obtained will be in its ones complement negative equivalent (which a computer can easily
understand).
• to simplify its reading (for humans), take 1’s complement of the result to convert it to its positive (actual)
binary equivalent and place a minus sign before it.
Ones complement arithmetic
• Case-3: Addition of two negative numbers:
• Take ones complement of both numbers and add the sign bits
• add them
• the final answer will be the ones complement of the sum.
• Example 1: Consider 1110 and -1101
• Example 2: Consider 1010 and -1100
• Example 3: Consider -1010 and -0101
Twos complement I -16 10000
… …
• So, addition and subtractions in ones complement are possible
• There is however still the problem of having two zeroes -3 11101
• Twos complement addresses this issue -2 11110
• In twos complement, every negative value is the sum of the inversion
of the bits in the positive binary value and 1 -1 11111
• Signed additions and subtractions are also possible in twos 0 00000
complement if rules are followed
• Range for this system is -2N-1 and 2N-1 – 1 +1 00001
• Observe, positive 0 is considered as the only 0 and negative 0 becomes +2 00010
-1
• Thus, positive numbers range from 0 to 15 (2N-1 – 1) and negative +3 00011
numbers range from -1 to -16 (-2N-1 )
… …
• The special cases and their rules are discussed in the slides that follow
+15 01111
Twos complement II
• First of all you need to note the following
• The original numbers given in all examples to be considered represent their
normal (positive) binary equivalent with a sign indicating their polarity
• An over flow bit refers to obtaining an extra bit of value 1 which is supposed
to precede the most significant bit (MSB) during the addition of two binary
numbers
• When we add or subtract in twos complement, an over flow bit of one
indicates that the result is positive (this does not include the case of adding
two negative numbers)
• Over flow bits are dropped
• In the absence of a carry bit, the result is negative
Twos complement addition
• There are three cases to consider in all
• Case-1 − Addition of positive and negative number when positive number has
greater magnitude (simple subtraction):
• take the 2’s complement of the negative number
• add the two numbers
• drop the overflow of 1 bit
• the final result is the first sum
• Case-2 − Addition of positive and negative number when negative number has
greater magnitude −
• Take the 2’s complement of the negative number
• add the two numbers
• since the result will be negative, there will not be an overflow
• take the two’s complement of the sum to obtain the final answer
Twos complement addition
• Case-3 − Addition of two negative numbers −
• take twos complement of both numbers
• add the two numbers
• the final answer will be the twos complement of the sum
• Example 1: Consider 1110 and -1101
• Example 2: Consider 1010 and -1100
• Example 3: Consider -1010 and -0101

You might also like