How Computers Work -  How it Performs Addition - Written by Stefan Ohlsson 

 
                                                 Image of a NOT logic gate ©Stefan Ohlsson 1997 

How a Computer Performs Addition 

Your computer is basically a large collection of switches. These switches are in the form of microscopic transistors etched into a slice of silicon. To visualise how it works you can imagine your computer as being a giant billboard with a lot of lights in different colours. Behind this billboard there is a control room in which there is a switch for each one of the coloured lights. By turning the right switches you can for example spell your name or draw a picture. Suppose now there are master switches that control a lot of other switches. By flipping a single master switch you can see different letters appears on the billboard.  

A master switch can turn on all light to create an A, a B and so on. For understanding how this works imagine your computer screen as the billboard, your RAM for the control room and your keyboard for the master switches. 

Your computer has, of course, more possibilities than display words on your screen. 
The on and off position on the same switches that are being used to control a display also can perform any kind of math by add numbers by representing the 0 and 1 in the binary number system. Maths is basically additions in different forms. Multiplication is repeated addition, subtraction is adding a negative number, and division is repeated subtraction. Your computer only understands numbers. It recognises all incoming data such as, math, words, numbers, and software, as numbers. In daily speech we call these switches transistors and they do all types of data manipulation. 

How a Computer Performs Addition - Step By Step 

1. All information in your PC is stored and manipulated in the form of binary  numbers. There are only two digits in the binary numerical system, 0 and 1. All words, graphics and numbers are formed from different combinations of those  two digits.     

 

2. Transistor switches are used to manipulate binary numbers by opening or closing  switches. When the switch is on or closed it allows a pulse of electricy from the  PC's clock to pass through. A closed switch represents a 1. If the switch is off or  open no pulse of electricity will pass through. An open switch represents a 0. A pulse that passes through a transistor can be used to control another transistor;  by turning the switch of and on to change what the second transistor represents. 
 This arrangement were two or more transistors are involved is called a gate. 

3. The simplest operation that a transistor can perform is called a NOT logic gate. It takes one input from the CPU clock and one from another transistor. A single  output is being produced by the NOT gate. This output is always the opposite of  the input from the other transistor.  The NOT gate consists of a single transistor. When an electrical pulse from another transistor is sent to a NOT gate, the gate's  own transistor switch opens and a pulse from the CPU clock can't flow through it.  This makes the NOT gate's output 0. (See image below) 
 A 0 input from another transistor closes the NOT gate's transistor so that the clock  pulse passes through it to produce an output of 1. 

  

4. NOT gates connected together in different combinations create other logic gates. All of these have a line to receive pulses from the clock and two other input lines  for pulses from other logic gates. If the first or the second input is a 1, the OR gate  creates a 1 

5. Only if the first and second input are 1s an AND gate outputs a 1.

6. If both the inputs are 1 or both the inputs are 0 an XOR gate outputs a 0.

7. Your computer uses different combinations of logic gates in order to perform the  math that is the foundation of all its operations. These gate designs are called 
 half-adders and full-adders. A half-adder consists of an AND Gate and an XOR  Gate. Both gates receive the same input signal. 
 A full-adder is a combination of half-adders and other switches

8. Your computer uses combinations of full-adders and half-adders to handle larger  binary numbers and generate results that involve carrying over numbers.
 
9. If you want to add the decimal number 2 and 3 (binary numbers 10 and 11) your  computer use a half-adder and a full-adder. The half-adder starts with processing  the digits on the right side through both XOR and AND gates. The result of the  XOR operation is the binary number 1 and becomes the rightmost digit of the  result.  

10.The half-adders result of its AND operation is the binary number 0. The binary  number 0 is sent to AND and XOR gates in the full adder. The full-adder also  processes the left-hand digits from 10 and 11 by sending both of them to another  AND gate and another XOR gate.

11.The results from ANDing and XORing the left-hand digits are processed with the  results from the half-adder. One of the new results in the full adder is passed  through and OR gate.

12.The result of this calculation is 101 in binary number, which is 5 in decimal  number. In order to work with larger numbers, more full adders are used - one for each digit in the binary numbers. If you have an 80386 or later processor in  your computer it uses 32 full-adders.