How does a computer work?

437 28 8
                                    

How does a computer work?

Computers are an essential part of our modern life. They seem to be popping up in everything, including appliances and TV’s. Let’s not forget that computer chips also run our smart phones. But, just how does a digital computer work? (There is another type of computer called an analog computer, but it isn’t used as much today).

First of all, one has to realize what digital means. This is easy. Digital, or binary, is a simple counting system where you only need one finger. The finger is up for a digital one and down for a digital zero. The reason why the binary system is used is because a transistor circuit has to be either on or off. When the circuit is on it means binary one and off stands for binary zero. This system is the only practical way to express a number in a computer because on or off are both very stable states for a transistor circuit. It represents a foolproof method. At one time they used relays and then vacuum tubes to express binary numbers, but integrated circuits have taken over because many transistor switches can be stuffed onto one integrated chip.

Numbers can be represented in computers by combining binary switching circuits to represent words, which are numbers with more than one binary digit. Computer memory words started out at four binary digits, eventually working up to eight, sixteen, thirty two, sixty four, one hundred twenty eight and beyond. The more binary digits one has in a word, the larger the number that can be represented. Each binary digit represents an increasing power of 2. The rightmost digit represents 2 to the zero power. The next leftmost digit is 2 to the 1 power and so forth. Decimal 1 or 2 to the zero is represented by binary 0001. Decimal 2 or 2 to the 1 power is represented by 0010. 4 or 2 to the 2 power is 0100 and 8 or 2 to the 3 power is 1000. Each location, starting on the right is a power of 2 higher.

Binary arithmetic is able to do any math that can be done with decimal numbers. This is accomplished by an integrated circuit component know as an Adder circuit, which not only adds binary digits, it produces sum and carry bits.

Binary math is odd because you can’t go above a digit 1. So 1 + 1 = 2 in decimal but 1 + 1 = 10 in binary. The carry goes to the left. Crazy, isn’t it?

Computer numbers are stored in registers in the processor. There are at least three (the latest microprocessors have many more registers). One register holds the word, the code and operand combination, obtained from memory. Another register, the program counter, holds the number that represents what line the main processor is on. Another register holds the previous word. Most of these registers are connected by parallel circuitry to allow an operation such as a move or an add in one clock cycle.

All computer processors work by employing two operations: one is the fetch cycle and the other is the execute cycle. A cycle is one signal from the computer’s clock circuit. The fetch cycle obtains a binary number out of memory (a place where the program is stored one line after another) indicated by the program counter ( a register that keeps track of how many lines of code have been processed). This binary number obtained from memory has two parts: an operand and an instruction code. During the execute cycle the code part tells the computer what to do with the operand part such as move it from one location to another, add it to another stored number in a register circuit, or send it to an external device. This is accomplished with a multiplexer circuit that decodes the instruction in the code part of the instruction to tell other circuits what to do with the operand by sending signals to them. The program counter is incremented by one to allow the entire operation to continue until the processor encounters a stop code. A loop instruction or code tells the processor to cycle through a designated series of instructions until told to jump out and continue with the next instruction that follows the loop series.

The program counter can be stored in a stack (a special memory location) while the fetch cycle obtains a memory word from another memory location. This is known as an interrupt. For example: when you press a key on your keyboard, a circuit in the keyboard tells the processor to stop doing what it’s doing and process a special program that’s associated with the keyboard. The processor gets the binary representation (ASCII) for the key that’s pressed and then sends it to the graphics chip to display the key number or letter that you pressed on a screen. After this is done, the processor returns from the interrupt operation by getting the program counter back from the stack and going on with what it was doing before it was rudely interrupted.

What I am describing here is machine code in which all programming code is in binary. This is the lowest of computer languages and it’s seldom done anymore because of the advent of higher languages such as C++. The earliest higher-level computer programming languages were BASIC, COLBOL, and Fortran. These languages use more human familiar terms and employ abstraction to shield the programmer from worrying about computer register manipulation and binary arithmetic. It’s hard to believe that brilliant programmers once created complicated computer games entirely in machine language. This is equivalent to Mozart writing a music score without mistakes, which is what he did.

It’s even harder to imagine how much has been stuffed into tiny processor circuits that seem to be in everything these days. Your smart phone computer processor is orders of magnitude more powerful than the mainframe computers of the sixties or even the eighties. Modern microprocessors can complete many parallel operations with a single clock cycle and have multiple processing cores to increase efficiency. Explaining how they work would be maddening.

I wrote this to give you a brief idea of how a computer works. It’s simply amazing what’s been accomplished in today’s tech, but when it gets down to the binary digits in a register, the method of operation of all computers is still the same as it was back in the dark ages of computing.

Thanks for reading.

The Theory of NothingWhere stories live. Discover now