SOME PUZZLING QUESTIONS AND THEIR ANSWERS

After reading the previous sections. the reader may have many unanswered ques­tions. One of the primary reasons for this predicament is that the microprocessor is a programmable and complex device. It interacts with external devices such as memory and I/Os. and some questions cannot be answered until we discuss these other devices. Similarly. some questions will remain unanswered until we start using instructions and writing programs. However. there are some questions that we should answer immediately. 

1. How does the Z80 microprocessor know where to begin after the power is turned on?

Most microcomputer systems have built-in power-on reset circuits , meaning that when the power is turned on, the microprocessor is reset and its program counter is cleared to the address 0000H , address 0000H is placed on the address bus and the instruction stored at that location determines what happens next.

2. How does the Z80 know what operation to perform first (Memory Read/Write , or I/O Read/Write)?

The first operation is always an Opcode Fetch.

3. How does the microprocessor differentiae between an opcode and a data byte ?

When the first opcode is fetched and decoded in the instruction register, the microprocessor recognizes the number of bytes that must be read from memory for the complete instruction. The instructions can range from 1 to 4 bytes in length. Figure 5. for example. contains a 2-byte instruction (3E and Data). and the second byte is always considered Data. If that second byte is omitted by mistake. the Z80 will interpret whatever is in that memory location as Data. The byte after the Data will be treated as the next instruction. The microprocessor is a sequential machine: it goes from -one memory location to the next unless in­structed to do otherwise.

4. What is the use of the M͞1 signal? It looks as if it will not be connected to any device.

This signal serves two purposes: (1) it differentiates the Opcode Fetch cycle from other operations. and (2) it can be used to generate the Interrupt Acknowledge signal.

5. if flags are individual flip-flops. can they be observed on an oscilloscope?

No, they cannot be observed on an oscilloscope; these flip-flops are internal and not connected to any of the external pins. However, they can be examined by storing them on the stack memory) (see Topic 10).

6. is the number of T-states required for a given machine cycle constant?

No, But most Opcode Fetch machine cycles require four T-states, and Mem­ory Read/Write and I/O Read/Write machine cycles, generally, take three or four T-states, However, there are some exceptions.

7. How does one recognize The machine cycles in a given instruction ?

The number of machine cycles and the T-states required for those machine cycles are listed in the instruction set , There is a repetitive pattern and one can use the following guidelines.
· The number of machine cycles in an instruction indicates how many times the microprocessor must access memory or I/O.
· The first machine cycle in an instruction is always Opcode Fetch.
· The microprocessor must read all the bytes (codes) from memory before it can execute an instruction .
For example, a 3-byte instruction requires at least three machine cycles. The unconditional Jump instruction is a 3-byte instruction with 10 (4,3,3) T-states; it consists of one opcode and a 16-bit address of the jump location. Therefore , by examining the number of T – states, we can easily classify the machine cycles of the Jump instruction as one 0 code Fetch and two Memory Read.
Another example is ADD . 32 (add a byte 32H to the contents of the accumulator). This is a 2-byte instruction with 7 (3) T-states. By examining the number of bytes and the number of T-states. We can conclude that it must have two machine cycle -the first is Opcode Fetch, and the second is Memory Read. The addition is performed inside the processor, and it does not need any addi­tional information from memory or I/O.

8. How does recognize machine cycles in an instruction when the number of bytes is not the same as the number of machine cycles?

One has to examine the number of bytes. T-states. and the operation being performed. For example, the instruction LD (2050H), A has three bytes and 13 (4, 3. 3. 3) T-states; it copies the contents of the accumulator into the memory loca­tion 2050H .The processor must read the entire instruction first: therefore. the first must be Opcode Fetch, followed by two Memory Read cycles. This accounts for ten T-states. In the remaining three states , the processor must write (copy) the contents of the accumulator into the memory location 2050H ;therefore. it must be the Memory Write cycle.

Leave a comment

Your email address will not be published. Required fields are marked *