These ones and zeros corresp ond to electrical switches b eing either on or o. Just
as 42 is a decimal numb er meaning \4 10s and 2 units", a binary number is a series
of binary digits each one representing a p ower of 2. In this context, a p ower means
the number of times that a numberismultiplied by itself. 10 to the p ower 1 ( 10
1
)
is 10, 10 to the power2(10
2
) is 10x10, 10
3
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 (2+8+32 or 2
1
+2
3
+2
5
). Rather than using binary
to representnumb ers in computer programs, another base, hexadecimal is usually
used. In this base, each digital representsapower 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, hexadecimal E is decimal 14 and hexadecimal 2A
is decimal 42 (two 16s) + 10). Using the C programming language notation (as I do
throughout this bo ok) hexadecimal numbers are prefaced by\
0x
"; hexadecimal 2A
is written as
0x2A
.
Microprocessors can perform arithmetic operations such as add, multiply and divide
and logical op erations such as \is X greater than Y?".
The processor's execution is governed by an external clo ck. This clo ck, the system
clock, generates regular clo ck pulses to the pro cessor and, at each clo ck pulse, the
processor does some work. For example, a pro cessor could execute an instruction
every 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,000 clo ck ticks every second. It
is misleading to describe the power of a CPU by its clo ck rate as dierent processors
perform dierent amounts of work per clock tick. However, all things b eing equal, a
faster clo ck sp eed means a more powerful pro cessor. The instructions executed by the
processor are very simple; for example \read the contents of memory at location X
into register Y". Registers are the micropro cessor's internal storage, used for storing
data and p erforming operations on it. The op erations p erformed may cause the
processor to stop what it is doing and jump to another instruction somewhere else in
memory. These tiny building blo cks give the mo dern micropro cessor almost limitless
power as it can execute millions or even billions of instructions a second.
The instructions have to be fetched from memory as they are executed. Instructions
may themselves reference data within memory and that data must b e fetched from
memory and saved there when appropriate.
The size, number and type of register within a microprocessor is entirely dependent
on its typ e. An Intel 4086 pro cessor has a dierent register set to an Alpha AXP
processor; for a start, the Intel's are 32 bits wide and the Alpha AXP's are 64 bits
wide. In general, though, any given pro cessor will haveanumber of general purpose
registers and a smaller number of dedicated registers. Most pro cessors have the
following special purp ose, 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 haveto have access to large amounts of external
read/write random access memory (RAM) which facilitates temporary storage
of data. The stackisaway of easily saving and restoring temp orary values in
external memory. Usually, pro cessors have sp ecial instructions which allowyou
to push values onto the stack and to pop them o again later. The stackworks