09.05.2015 Views

Microcomputer Circuits and Processes

Microcomputer Circuits and Processes

Microcomputer Circuits and Processes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Execute<br />

cycle number<br />

The program in detail looks like this:<br />

The number 0111 is put into reg A, where it will be used as an address in<br />

the MOV M -+ Acc instruction in EXECUTE cycle 2, <strong>and</strong> the<br />

MOV Acc -+ M instruction in EXECUTE cycle 5.<br />

2 The contents of memory whose address 0111 is in reg A is moved into<br />

the accumulator. So 0110 (6 10 ) ends up in the accumulator.<br />

3 <strong>and</strong> 4 The number immediately following the ADI instruction, the number<br />

0101 (5 10 ), is added to the accumulator, <strong>and</strong> the results stored in the<br />

accumulator.<br />

5 The accumulator contents 1011 (11 10 ) are moved to memory whose<br />

address (0111)is in reg A.<br />

6 Stop. The computer comes to a halt.<br />

The memory location referred to by reg A which initially held the<br />

number 6 10 , ends up receiving the result (11 10 ).<br />

RUNNING THE PROGRAM<br />

Now you are familiar with SAM's instructions, <strong>and</strong> have seen the<br />

assembled program, we come to the real task of this chapter: looking in<br />

detail at data flows <strong>and</strong> signal changes as the program is run.<br />

Remember from Chapter 2 that the CPU contains a clock, <strong>and</strong> three<br />

clock periods are needed to carry out either a READ or a WRITE<br />

operation. These two operations are all that is needed to run the<br />

program. Remember that the instructions live in memory, so each<br />

instruction has to be FETCHed before it can be EXECUTEd. This<br />

gives us two cycle types, FETCH <strong>and</strong> EXECUTE, which run in<br />

sequence as shown in figure 3.11.<br />

1 clock<br />

period<br />

~<br />

CPU clock<br />

FETCH I EXECUTE FETCH I EXECUTE FETCH<br />

1st instruction<br />

)!<<br />

2nd instruction '3rd instruction<br />

Figure 3.11<br />

Showing how each instruction is made up of FETCH <strong>and</strong> EXECUTE cycles, which in<br />

turn are made up of three CPU clock periods.<br />

What actually goes on during the EXECUTE cycle depends on<br />

what instruction is being executed. But the FETCH cycles are always<br />

the same for any instruction; so begin by looking at a fetch cycle.<br />

33

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!