Posts

Showing posts with the label Introduction to Z80 Assembly Language Programming

ASSIGNMNTS on Introduction to Z80 Assembly Language Programming

ASSIGNMNTS 1. How is the accumulator different from the 8-bit general-purpose registers of the Z80 microprocessor? 2. Explain the function of the alternate registers. 3. What is a flag, and what is its function? 4. If the Z80 adds 87 H and 79 H , specify the contents of the accumulator and the status of the S, Z, and CY flags. 5. If the Z80 is an 8-bit microprocessor, why are the program counter and the stack pointer 16-bit registers? 6. If the Z80 has fetched the machine code located at the memory location 205F H , specify the contents of the program counter. 7. The index register IX holds the address 2058 H • Specify the value of the dis­placement byte needed to make the effective address 2097 H • 8. The index register IY holds the address 2070 H • Specify the value of the dis­placement byte in 2's complement needed to make the effective address 2050 H • 9. List the six types of operations the Z80 performs. 10. Define opcode and operand, and specify the opcod...

SUMMARY of Introduction to Z80 Assembly Language Programming

SUMMARY This chapter introduced the Z80 programming model and provided an overview of the Z80 instruction set and the capability of the Z80 microprocessor. The im­portant concepts and topics discussed in this chapter can be summarized as follows: · The Z80 microprocessor has six general-purpose 8-bit registers (B, C, D, E, H, and L) as a primary set. In addition, it includes the alternate set of these registers, all of which can be used to exchange information with the primary set. The registers Band C, D and E, and Hand L can be combined to perform some l6-bit operations. · The ALU section of the Z80 includes accumulator A and the flag register to indicate six different data conditions. It also includes the alternate accumula­tor A' and flag register F', which can be used to exchange information with A and F, respectively. · Four flags-Sign, Zero, Carry, and Parity/Overflow-can be used for decision making and tested in connection with Jump, Call, and Return instruction...

LIST OF SELECTED Z80 INSTRUCTIONS par 2

Most instructions are compatible with the 8080 instruction set, with a few exceptions. Notations used in the description of the instructions include r = Z80 8-bit Register rp = Register Pair r s = Register Source rx = Index Registers r d = Register Destination d= Displacement Byte m = Memory b = Bit ( ) = contents of l6-bit Memory Address or 8-bit I/O Address 1. Data Copy (Load) Instructions Mnemonics Bytes Tasks Data (8 bits and 16 bits) copy or load in...

LIST OF SELECTED Z80 INSTRUCTIONS

6.6 LIST OF SELECTED Z80 INSTRUCTIONS The Z80 instruction set includes 158 instructions resulting in 694 machine codes. The following list is a representative sample of each group described in Section "'6.2. The purpose of the list is to show you the overall capability of the Z80 and some logical patterns in its instruction. You should not study these instructions in detail; instead, you should search for logical patterns. Once you recognize log­ical patterns, you will be able to recognize the function of an instruction even if you have not seen it before. Z80 Addressing Modes Explanation Example 1. Immediate The byte following the opcode is the operand. This mode is used to load 8-bit data into a register. LD B, 97H 2. Immediate Extended ...

ADDRESSING MODES

Image
6. 5 ADDRESSING MODES The addressing mode is a way of specifying an operand or pointing to a data location. The Z80 microprocessor has ten addressing modes, as shown in Table 6.1. The first three are explained here as illustrations, and the others will be explained in later chapters. In Section 6.2.2, we listed various categories of data copy operations. Data can be loaded directly into registers (or memory), or they can be copied from registers and memory, including I/O ports. Here are the addressing modes of these data copy operations. At this point, you are unfamiliar with the instruction types; therefore, you should avoid the details of the addressing modes given in Table 6.1. As we begin to use various instructions in following chapters, we will discuss the appropriate addressing modes. As you become more familiar with the instruction set, you will be able to choose an appropriate addressing mode for a given task.

FLOWCHARTING

Image
6.4 FLOWCHARTING A flowchart is a graphic representation of the logic and sequence of tasks to be performed. A flowchart should assist in clarifying one's thinking process and communicate the programmer's approach and logic in writing the program. Flowcharting is an art; how much detail it should include requires a subjec­tive decision. At one level, the flowchart includes only the functions to be per­formed without any reference to a particular microprocessor; at another level, the functions of registers being used are specified in detail. However, it should not duplicate the instructions in the program in a graphic format; this would defeat the whole purpose of drawing the flowchart. It should simply represent a logical approach and sequence of steps in solving the problem. The six symbols commonly used in flowcharting are shown in Figure 6.7. We have already used three symbols in Figure 6.5. The fourth symbol, shown by the diamond shape, represents the decision-making ...

HOW TO WRITE, ASSEMBLE, AND EXECUTE A SIMPLE ASSEMBLY LANGUAGE PROGRAM

Image
6.3 HOW TO WRITE, ASSEMBLE, AND EXECUTE A SIMPLE ASSEMBLY LANGUAGE PROGRAM An assembly language program is a sequence of instructions written in mnemon­ics to perform a specific task. These instructions are selected from the instruction set of the microprocessor being used. To write a program, we need to divide a given problem into small steps and translate these steps into the operations the Z80 can perform. For example, the Z80 does not have an instruction that can multiply two' binary numbers, but it can add. Therefore, the multiplication prob­lem can be written as a series of additions. After writing the instructions in mnemonics, you should translate them in to binary machine code; this process of translation is called assembling the code Quite often, this process involves intermediate steps, such as translating mnemonics into Hex code and then into binary code. The code assembly can be done manually, as described in this chapter, or using an assembler (a program that tran...

6.2 OVERVIEW: Z80 INSTRUCTION SET

Image
6.2 OVERVIEW: Z80 INSTRUCTION SET The instruction set of a microprocessor determines the capability of its opera­tions, the power of its data manipulation, and the ease of programming it. Al­though it is necessary to have an overall view of the instruction set, our intent here is merely to acquaint you with the overall operations and capability of the Z80 microprocessor. As you progress through the chapters of Part II, you will be exposed to various instructions in more detail along with their applications. The Z80 microprocessor has 158 instruction types; it includes all the instruc­tions of the Intel 8080 microprocessor and all but two of the 8085. As discussed in Chapter 1, each instruction has two parts: one is the task to be performed (such as Load, Add, and Jump), called the operation code (opcode); and the second identifies the data to be operated on, called the operand. First, we will examine various formats of these instructions in terms of number of bytes and then their c...

6.1 THE Z80 PROGRAMMING MODEL

Image
6.1 THE Z80 PROGRAMMING MODEL In Chapter 2, we developed a model to represent the internal structure of the MPU shown in Figure 2.3. We will now describe a similar model of the Z80 micropro­cessor; however, we will include only those components necessary for the pro­grammer. Figure 6.1 shows such a model, which includes an accumulator and a flag register, general-purpose register arrays, registers used as memory pointers, and special-purpose registers. These registers and their functions were described briefly in Chapter 3 in the context of the Z80 architecture; now, they are described in detail in the following sections. 6.1.1 Accumulator The accumulator is an 8-bit register that is part of the Arithmetic/Logic unit (ALU) and is also identified as register A. This register is used to store 8-bit data and to perform arithmetic and logic operations. The result of an operation performed in the ALU is also stored in the accumulator. For example, in an 8-bit addition...

Introduction to Z80 Assembly Language Programming

Introduction to Z80 Assembly Language Programming An assembly language program is a set of in­structions, written in the mnemonics of a given microprocessor, and in a sequence appropriate to a specified task. To write such programs, we should be familiar with the programming model (internal registers) of the microprocessor and its instruction set. This chapter introduces the Z80 programming model and provides such an over­view of the Z80 instruction set. The Z80 instruction set is classified into six categories, and each category is explained with examples. The chapter also discusses the instruction format and various addressing modes, Writing, assembling, and executing a program are illustrated by a simple problem of adding two Hex numbers. The flowcharting technique and symbols are discussed in the context of the illustrative program. The chap­ter concludes with a list of selected Z80 instructions: OBJECTIVES · Draw the Z80 programming model and iden­tify the registers. · E...