next up previous contents
Next: Memory Up: Hardware Basics Previous: Hardware Basics

The CPU

      The CPU, or rather microprocessor, is the heart of any computer system. The microprocessor calculates, performs logical operations and manages data flows by reading instructions from memory and then executing them. In the early days of computing the functional components of the microprocessor were seperate (and pysically large) units. This is when the term Central Processing Unit was coined. The modern microprocessor integrates these components onto an integrated circuit etched onto a very small piece of silicon. The terms CPU, microprocessor and processor are all used interchangeably in this book.

Microprocessors operate on binary data; that is data composed of ones and zeros.   These ones and zeros correspond to electrical switches being either on or off. Just as 42 is a decimal number meaning ``4 10s and 2 units'', a binary number is a series of binary digits each one representing a power of 2. Here a power means the number of times that a number is multiplied by itself. 10 to the power 1 ( tex2html_wrap11477 ) is 10, 10 to the power 2 ( tex2html_wrap11478 ) is 10x10, tex2html_wrap11479 is 10x10x10 and so on. Binary 0001 is decimal 1, binary 0010 is decimal 2, binary 0011 is 3, binary 0100 is 4 and so on. So, 42 decimal is 101010 binary or ( tex2html_wrap11480 or tex2html_wrap11481 ). Rather than using binary to represent numbers in computer programs, another base, hexidecimal is usually used.   In this base, each digital represents a power of 16. As decimal numbers only go from 0 to 9 the numbers 10 to 15 are represented as a single digit by the letters A, B, C, D, E and F. For example, hexidecimal E is decimal 14 and hexidecimal 2A is decimal 42 (two 16s) + 10). Using the C programming language notation (as I do throughout this book) hexidecimal numbers are prefaced by ``0x''; hexidecimal 2A is written as 0x2A .

Microprocessors can perform arithmetic operations such as add, multiply and divide and logical operations such as ``is X greater than Y?''. The processor's execution is governed by an external clock. This clock, the system clock, generates regular clock pulses to the processor and, each clock pulse, the processor does some work. For example, a processor could execute an instruction ever clock pulse. A processor's speed is described in terms of the rate of the system clock ticks. A 100Mhz processor will receive 100,000 clock ticks every second. It is misleading to describe the power of a CPU by its clock rate as different processors perform different amounts of work every clock tick. The instructions are very simple; for example ``read the contents of memory at location X into register Y''. Registers are the microprocessor's internal storage, used for storing data and performing operations on it. The operations performed may cause the processor to stop what it is doing and jump to another instruction somewhere else in memory. These tiny building blocks give the modern microprocessor almost limitless power as it can execute millions or even billions of instructions a second.

Registers are used for internal storage of addresses, instructions and data. The size, number and type of register within a microprocessor are entirely dependent on its type. An Intel 4086 processor has a different register set to an Alpha AXP processor; for a start, the Intel's are 32 bits wide and the Alpha AXPs are 64 bits wide. In general, though, any given processor will have a number of general purpose registers and a smaller number of dedicated registers. Most processors have the following special purpose, dedicated, registers:

Program Counter (PC)
This register contains the address of the next instruction to be executed. The contents of the PC are automatically incremented each time an instruction is fetched,
Stack Pointer (SP)
Processors have to have access to large amounts of external read/write memory (RAM) which facilitates temporary storage of data. The stack is a way of easily saving and restoring temporary values in external memory. Ofter processors have special instructions which allow you to push values onto the stack and to pop them off again later. The stack works in a first in last out (LIFO) basis.
Processor Status (PS)
Instructions may yield results; for example ``is the contents of register X greater than the contents of register Y?'' will yield true or false as a result. The PS register holds this and other information about the current state of the processor. Most processors have at least two modes of operation, kernel (or supervisor) and user. The PS register would hold this information too.


next up previous contents
Next: Memory Up: Hardware Basics Previous: Hardware Basics

David A. Rusling
david.rusling@reo.mts.dec.com