The document discusses integer representation and arithmetic logic unit (ALU) operations in computers. It describes how integers are represented using binary digits and two's complement notation. The ALU performs calculations on these binary integers. It can handle standard integer arithmetic as well as floating point numbers, potentially with a separate floating point unit.
2. ARITHMETIC & LOGIC UNIT
Does the calculations
Everything else in the computer is there to
service this unit
Handles integers
May handle floating point numbers
May be separate FPU
4. INTEGER REPRESENTATION
Only have binary digits (0 & 1) to represent
numbers.
Positive numbers stored in binary
e.g. 41=00101001
Sign-Magnitude
Two’s compliment
5. An 8 -bit word can represent the numbers from
0 to 255,including
00000000 = 0
00000001 = 1
00101001 = 41
10000000 = 128
11111111 = 255
If an n-bit sequence of binary digits an-1an-2…a1a0 is
interpreted as an unsigned integer A, its value is
A= i
n
i
i
a
1
0
2
6. SIGN-MAGNITUDE
Left most bit is sign bit
0 means positive
1 means negative
If there are n bits, then rightmost n-1 bits hold the magnitude of
the integer.
+18 = 00010010
-18 = 10010010
7. Problems
Need to consider both sign and magnitude in
arithmetic
Two representations of zero (+0 and -0)
(e.g) +010 =00000000
-010 =10000000
9. BENEFITS
One representation of zero
Arithmetic works easily
Negating is fairly easy
3 = 00000011
Boolean complement gives 11111100
Add 1 to LSB gives 11111101
10. VALUE BOX FOR CONVERSION BETWEEN
TWOS COMPLEMENT BINARY AND DECIMAL
11.
12. SOLUTION
Move the sign bit to the new leftmost position and fill in with
copies of the sign bit.(Sign Extension)
-18 = 11101110(twos complement,8 bits)
-18 = 1111111111101110(twos complement,16 bits)
13. NEGATION
Rules:
1) Take the Boolean complement of each bit of the
integer.(including the sign bit)
2) Treating the result as an unsigned binary integer , add
1.
Eg) +18 = 00010010
bitwise complement = 11101101
1 +
11101110 = -18
14. NEGATION SPECIAL CASE 1
0 = 00000000
Bitwise not 11111111
Add 1 to LSB +1
Result 1 00000000
Overflow is ignored, so:
- 0 = 0
15. NEGATION SPECIAL CASE 2
-128 = 10000000
bitwise not 01111111
Add 1 to LSB +1
Result 10000000
So:
-(-128) = -128