In these two lectures we look at how a processor executes programs in its simplest form.
The first thing to realize is that everything inside the computer is binary. It's all represented by bits that can be ON or OFF, 1 or 0.
The memory can be thought of as a tall array of cells. The cells are referred to as memory cells, or memory words.
Each cell is numbered, and the number is called the address of the cell. The numbering system goes from 0 to a very large number. This number is directly related to the size of the memory. If you have a PC with 8 Megabytes of Random Access Memory (RAM), then your memory contains roughly 8 million cells, each with its own address: 0, 1, 2, 3, 4, .... 8,000,000 (in reality it's 8,388,608 which corresponds to 2^23).
In order for the processor to access memory and either store or read information from it, it needs a collection of wires to attach it to the memory. There are two main such "collections" of wires. They are called buses. One is referred to as the address bus, the other one as the data bus.
The address bus allows the processor to send a number to the memory. This number, made of 1s and 0s represents the address of a cell the processor needs wants to access. When the memory receives this address, a series of decodes (electronic circuits made of and, or and not gates) selects the cell whose address matches the number on the address bus, and dumps the contents of the cell onto the second bus. This second bus, the data bus, brings the information to the processor, where it is "processed."
What type of information will we find flowing on the data bus? Binary information. Just bits! For the processor to do something meaningful, we need to "code" this information. One way to do that is to specify patterns of 1s and 0s to mean something specific to the processor. We will refer to them as instructions.
Instructions tell the processor to perform simple operations:
For the processor to be able to deal with numbers stored in the memory, in needs places to hold these numbers in. These places are called registers.
We will write program for a simple processor modeled after the Pentium processor. This processor does not exist because it is too simple by today's standards, but it is sophisticated enough for us to write small programs that will give us a very precise idea of what real processors do.
Our simplified processor contains 4 data registers, or general purpose registers: AX, BX, CX, and DX. One index register, SI, one instruction pointer register IP, and two flag bits, LessThan and Equal (more on them later!)
The simplified processor supports the following instructions:
Stay tune for examples of small demo programs utilizing the above instructions!