Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 9 COMPUTER ARITHMETIC - ALU

Similar presentations


Presentation on theme: "CHAPTER 9 COMPUTER ARITHMETIC - ALU"— Presentation transcript:

1 CHAPTER 9 COMPUTER ARITHMETIC - ALU
CSNB123 coMPUTER oRGANIZATION NSMS2013 Ver.1 Systems and Networking

2 Overview NSMS2013 Ver.1 Systems and Networking
Arithmetic Logic Unit (ALU) Focus on – computer arithmetic Logic function Support 2 types of number Integer Floating-point Component in processor NSMS2013 Ver.1 Systems and Networking

3 ALU Part of the computer that do the arithmetic and logical operation on data Simple digital logic devices that can; Store binary digits Perform simple BOOLEAN logic operations CPU Registers Arithmetic Logic Unit (ALU) Internal CPU Interconnection Control Unit NSMS2013 Ver.1 Systems and Networking

4 Systems and Networking
ALU Interconnection NSMS2013 Ver.1 Systems and Networking

5 ALU and Registers CPU Component Description Registers
Present data to ALU Store result of an operation Temporary storage locations within the processor that are connected by signal paths to the ALU ALU set flags – result of an operation – store in registers Control unit Provides signals that control; Operation of the ALU Movement of the data into and out of the ALU CPU Registers Arithmetic Logic Unit (ALU) Internal CPU Interconnection Control Unit NSMS2013 Ver.1 Systems and Networking

6 Integer Representation
Computer - logic circuits - operate on information; 0 and 1  two values electrical signals – bit How to represent negative value in binary? Sign-magnitude representation Twos complements representation NSMS2013 Ver.1 Systems and Networking

7 Sign Magnitude Representation
NSMS2013 Ver.1 Systems and Networking

8 Sign-magnitude Representation
Ways of presenting -ve and +ve integers The most significant (leftmost) bits in the word as a sign bit Example: if the sign bit is 0 then the number is +ve, vice versa Hence sign magnitude representation employed sign bit NSMS2013 Ver.1 Systems and Networking

9 Sign-magnitude Representation (Cont.)
Example +18 = -18 = Rarely used Drawbacks; Addition/subtraction require a consideration of both the signs of the numbers and their relative magnitudes to carry out the required operation 2 representation of 0; +010 = -010 = NSMS2013 Ver.1 Systems and Networking

10 Twos complements representation
NSMS2013 Ver.1 Systems and Networking

11 Twos Complements Representation
Used the most significant bit (MSB) as a sign bit (similar to sign magnitude) Differs – the other bits are interpreted Example: +3 = +2 = +1 = +0 = NSMS2013 Ver.1 Systems and Networking

12 Twos Complements Representation (Cont.)
Negative – sign bit = 1 Example: -1 = -2 = -3 = NSMS2013 Ver.1 Systems and Networking

13 Twos Complements Representation (Cont.)
Steps for negative integers. Example: -3 +3 = 1 Step 1: Take +ve value Step 2: Boolean Complement Step 3: Add 1 to LSB Result NSMS2013 Ver.1 Systems and Networking

14 Twos Complements Representation (Cont.)
Example: 1 = 16 -16 Step 1: Take value Step 2: Boolean Complement Step 3: Add 1 to LSB Result Convert into decimal Put –ve sign NSMS2013 Ver.1 Systems and Networking

15 Twos Complements Representation – Special Case
Example: 0, consider an 8-bit representation 1 Step 1: Take value Step 2: Boolean Complement Step 3: Add 1 to LSB Result 1 carry out at most significant bit (MSB) - Ignored hence -0 = 0 NSMS2013 Ver.1 Systems and Networking

16 Twos Complements Representation – Range of Numbers
8-bit 2s complement +127 = -127 = 16-bit 2s complement = = NSMS2013 Ver.1 Systems and Networking

17 Twos Complements Representation – Conversion between lengths
Positive Negative Pack with leading zeros 8-bits +18 = 16-bits -18 = Pack with leading ones 8-bits +18 = 16-bits -18 = NSMS2013 Ver.1 Systems and Networking

18 Twos Complements Representation - Operations
Addition Subtraction NSMS2013 Ver.1 Systems and Networking

19 Twos Complements Representation - Operations
Addition Addition follows as if the two numbers were unsigned integers (positive or zero) Overflow – result is larger than word ALU provide signals NSMS2013 Ver.1 Systems and Networking

20 Twos Complements Representation - Operations
Subtraction Do subtraction via addition NSMS2013 Ver.1 Systems and Networking

21 Twos Complements Representation - Operations
OVERFLOW RULE If two numbers are added, and they BOTH are POSITIVE or BOTH NEGATIVE, Then OVERFLOW occurs if and only if the RESULT has the OPPOSITE SIGN NSMS2013 Ver.1 Systems and Networking


Download ppt "CHAPTER 9 COMPUTER ARITHMETIC - ALU"

Similar presentations


Ads by Google