Computer Organization and Architecture

Computer Arithmetic

Arithmetic & Logic Unit
z ALU- part of the computer that actually performs arithmetic and logical operations z All other elements of computer like Control unit, registers, memory, I/O- bring data into the ALU for it to the process z Handles integers z May handle floating point (real) numbers z Data are presented to ALU in register and the result are stored in Registers

ALU (cont…)
z These Registers- temporary storage locations within the processor that are connected by single path to ALU z Overflow flag is set to 1, the result of a computation exceeds the length of the register z Control Unit – control the operation of the ALU

ALU Inputs and Outputs

Integer Representation
z In the Binary System- Only have 0 & 1 to represent everything z If we are limited to non-negative (Positive numbers) stored in binary, the method is straight forward
y e.g. 41=00101001

Cont..
The operation of the multiplier is as follows 1. Control logic reads the bits of the multiplier one at a time. 2. If Q0 is 1, then the multiplicand bit is added to the A register and the result is stored in the A register, C bit is used for Overflow 3. Then all the bits of the C, A and Q register and shifted to the right one bit, so the C bit goes to An-1 …., A0 goes into Qn-1 and Q0 is lost 4. If Q0 is 0, then no addition is performed.

Example

Flowchart for Unsigned Binary Multiplication

Multiplying Negative Numbers

This does not work! Solution 1
Convert to positive if required Multiply as above If signs were different, negate answer

Solution 2
Booth’s algorithm

Booth’s Algorithm

Example of Booth’s Algorithm

Division

More complex than multiplication Negative numbers are really bad! Based on long division

FP numbers are usually normalized i.e. exponent is adjusted so that leading bit (MSB) of mantissa is 1 Since it is always 1 there is no need to store it (c.f. Scientific notation where numbers are normalized to give a single digit before the decimal point e.g. 3.123 x 103)