Introduction to Z80 Instructions and Programming Techniques
When a microcomputer is asked to execute a program stored in its memory, it reads one instruction at a time and performs the task specified by the instruction. Each instruction in the program is a command, in binary, to the microprocessor to perform an operation. In Chapter 6, we examined briefly the Z80 instruction set and its capability. In this chapter, we will introduce a few selected instructions and illustrate them with examples. These instructions are selected from three groups: data copy, arithmetic, and branch operations.
A computer is at its best, relative to human capability, when it is asked to repeat such. Simple tasks as adding or copying. The programming techniquesــــ such as looping, indexing, and countingــــ necessary to perform such tasks are introduced and illustrated with two programs. This chapter also includes a brief discussion of debugging programs.
Finally, a group of special Z80 instructions that perform multiple tasks are introduced with illustrative examples.
OBJECTIVES
· Explain the functions of data copy instructions and how the contents of the source register and the destination registers are affected.
· List four types of data copy operations and explain the term addressing mode.
· Explain how a memory address is specified to copy data from and to a memory register.
· Explain how data are transferred from and to I/O devices.
· Explain the functions of arithmetic instructions (ADD, SUB, INC, DEC) and how flags are affected by these instructions.
· Write a set of commands using data copy and arithmetic instructions to perform a given task.
· Explain the functions of unconditional and conditional jump instructions and how they are used for decision making.
· Draw a flowchart of a conditional loop to illustrate the indexing and counting techniques.
· List the seven blocks of a generalized flowchart illustrating data acquisitions and data processing.
· Write a program to copy data from one block of memory to another block including the case of overlapping blocks.
· Write a program to perform arithmetic operations on given data stored in memory.
· List the types of errors that frequently occur in writing assembly language programs and in hand assembling the code. Recognize the errors in a given program.
· List Z80 special instructions and explain how they provide more flexibility and improve efficiency in writing Z80 programs.
· Modify the previously written programs using the Z80 special instructions.