You are on page 1of 17

THE ARITHMETIC AND LOGIC UNIT

The ALU is that part of the


computer that actually
arithmetic and logical
operations on data. All of
the other elements of the
computer system. An ALU and,
indeed, all electronic components in the computer are based on
the use of simple digital logic devices that can store binary
digits and perform simple Boolean logic operations. ( )

Figure 2.3
Expanded Structure of IAS
Computer on page 22 (William
Stallings Computer
Organization and
Architecture Designing
for Performance
(8th edition).pdf)
INSIDE THE ALU

INTEGER REPRESENTRATION
WHAT IS INTEGER REPRESENTATION
To fully understand how binary numbers are processed we must
have an understanding of how integers are handle by the
computer. For instance:
How are negative numbers represented?
How are floating point numbers represented?
Processing how we add, subtract, divide and multiply?

INTEGER REPRESENTATION
In the binary number system, arbitrary numbers can be
represented with just the digits zero and one, the minus sign,
and the period, or radix point. For purposes of computer storage
and processing, however, we do not have the benefit of minus
signs and periods. Only binary digits (0 and 1) may be used to
represent numbers. If we are limited to nonnegative integers,
the representation is straightforward.

SUB-TOPICS
Sign-Magnitude Representation
Twos Complement Representation
Converting between Different Bit Lengths
Fixed-Point Representation

Sign-Magnitude Representation
There are several alternative conventions used to represent
negative as well as positive integers, all of which involve
treating the most significant (leftmost) bit in the word as a sign
bit ( ). The general rule is that, if the sign bit is 0, the number is
positive; if the sign bit is 1, the number is negative. To simplify,
positive numbers starts with 0 and negative numbers starts with
1. The simplest form of representation that employs a sign bit is
the sign-magnitude representation. In an n-bit word, the
rightmost bits hold the magnitude of the integer.

An8-bit number can have 1-bit sign and 7-bit magnitude


Largest Positive Number: 0 1111111
+127
Largest Negative Number: 1 1111111
-127
Range: -127 to +127
To negate a number, just invert the sign bit.
-(0 0100001) = 1 0100001
-(1 0000101)= 0 0000101

Ones Complement
What is a Complement?
It is the opposite of something.
Because computers do not like to subtract, this method finds the
complement of a positive number and then addition can take
place.
First method
Steps:
1.Convert number to binary
2.Swap all the bits
3.Check answer by adding 127
.(SHOW EXAMPLE!!)

Second method
Given a number x which can be expressed as an n-bit binary
number, its negative value can be obtained in Ones
Complement representation using: -x= 2n-x-1
Example:
With an 8-bit number 00001100, its negative value, expressed in
Ones Complement, is obtained as follows:
(SHOW SOLUTION!!)
(APPLY THE FIRST METHOD WITH THE SAME GIVEN)

Twos complement
The only difference between two processes is that the left most bit
is -128 rather than -127.
First method
The process for Twos complement is exactly the same as ones
complement, however you are then required to add 1 to the results
Steps:
1.Convert number to binary
2.Swap all the bits
3.Add 1 to the result
(SHOW EXAMPLE)
(Show the use of value box)

Second method
Given a number x which can be expressed as an n-bit binary
number, its negative number can be obtained in Twos
Complement representation using: -x= 2n-x
Example: With an 8-bit number 00001100, its negative value in
Twos Complement is thus:
(SHOW SOLUTION!!)
(APPLY STEP 3 OF FIRST METHOD)
(ANSWER IS NEGATIVE)

Converting between Different Bit Lengths

This procedure will not work for twos complement


negative
integers. Instead, the rule for twos complement integers is to
move the sign bit to the new leftmost position and fill in with
copies of the sign bit. For positive numbers, fill in with zeros,
and for negative numbers, fill in with ones. This is called sign
extension.

Decimal-to-Binary Conversion
Method 1: Sum-of-Weights Method
Method 2: Repeated Division-by-2 Method (for whole numbers)
Repeated Multiplication-by-2 Method (for fractions)
Sum-of-Weights Method
Determine the set of binary weights whose sum is equal to the
decimal number.
9= 8 + 1 = 23 +20 = 1001
18= 16 + 2 = 24 +21 = 10010
58= 32 + 16 + 8 + 2 = 25 +24 +23 +21 = 111010
0.625= 0.5 + 0.125 = 2-1 +2-3 = 0.101

Repeated Division-by-2 Method


To convert a whole number to binary, use successive division by
2until the quotient is 0. The remainders form the answer, with
the first remainder as the least significant bit (LSB) and the last
as the most significant bit (MSB).

Repeated Multiplication-by-2 Method


To convert decimal fractions to binary, repeated multiplication
by 2 is used, until the fractional product is 0 (or until the desired
number of decimal places). The carried digits, or carries,
produce the answer, with the first carry as the MSB, and the last
as the LSB.

Fixed-Point Representation
This method assumes the decimal point is in fixed position.
Example: 10011101=10011.101
Therefore
16 + 2 + 1 = 19
0.5 + 0.125 = 0.625
So 10011.101 = 19.625
Representation of Fraction
Fractional number are numbers between 0 and 1.
Example: 23.714 = 01101.1001
Problems are:
You fix the number that you can represent. You are limited to amount of
numbers that you can actually represent.

You might also like