Microcomputer Circuits and Processes
Microcomputer Circuits and Processes
Microcomputer Circuits and Processes
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
adding is represented by 1111. Figure 3.4 shows this instruction stored<br />
somewhere in SAM's memory. A whole program, made up of more<br />
instructions plus some data, is stored in memory as a long list of 4-bit<br />
numbers.<br />
other instructions<br />
or data<br />
-<br />
4-bit memory<br />
--0 1 1 0<br />
1 1 1<br />
-<br />
--<br />
1-<br />
instruction<br />
-- 0 1 0 1<br />
0 1 1 1<br />
ADD<br />
Figure 3.4<br />
A section of memory, showing the instruction for addition in one memory location.<br />
How does the CPU actually execute a program? First, it must fetch<br />
the instruction from the memory, by READing memory. But how does<br />
it know which memory location to read next? This is the job of the<br />
program counter register in the CPU, which holds a 4-bit number - the<br />
address of the instruction to be dealt with next. When SAM is switched<br />
on, the program counter (PC) is reset to 0000. As the program runs, so<br />
the PC is incremented, usually fairly steadily, as shown in figure 3.5.<br />
addresses<br />
(in binary)<br />
PC~<br />
1------1<br />
PC~<br />
1-------1<br />
~<br />
0000<br />
0001<br />
0010<br />
001 1<br />
PC<br />
~<br />
points to zero<br />
at power-up<br />
... later ...<br />
... later .. ,<br />
Figure 3.5<br />
Showing how the program counter points to memory locations. Low memory addresses<br />
are near the top.<br />
Some instructions like JUMP or CALL SUBROUTINE may send<br />
the PC bouncing around anywhere within memory. Wherever the<br />
instruction comes from, the CPU now has to interpret it, <strong>and</strong> execute it.<br />
28