





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






In its basic operation the central processing unit alternates between fetching instructions and executing instructions. The instructions cause the processor to manipulate the contents of specific programming model register- and of memory and I/O locations. Certain types of instructions. namely load/store, arithmetic logic, and input/output, must identify specific registers and/or locations for the processor in order that it may locate operands or store results property. Test branch instructions must also identify the branch target locations in the program. This chapter examines the various classes of instructions which processors must be able to execute.
The computer can do certain basic types of operations: load/store, arithmetic logic, test/branch, and input/output. Although the instructions which direct these operations in the central processing unit vary widely from processor to processor, certain common characteristics are found in all processor instruction sets.
Load/store operations are those which move data between a register in the processor and a memory location (or another register). They are often collectively referred to as data movement instructions. The two terms load and store are often confused and should be carefully distinguished from each other. Figure 5.1 illustrates the difference.
FIGURE 5.1Load and store operations: (a) load, (b) store.
One of the universal characteristics of instruction execution is that the source does not get changed, only the destination. Thus, in a load operation the processor copies data into a register, and in a store operation the processor copies data from a register into a memory location. Examples of load/store instructions in the MC6809 are LDA, STA, LDB, STB, LDD, STD, and so forth. Examples of load/store instructions in the MC68000 are MOVE (for either direction of data movement), MOVEM (for moving the content of several registers into or out of memory with a single instruction), and EXG (for exchanging register contents). These instructions and others like them must include information identifying the source and destination.
Arithmetic/logic operations provide the primary data-processing capabilities of the computer. The minimum arithmetic operations required are those of addition and subtraction. All processor, implement the basic logic operations of AND, OR, and exclusive-OR on a bit-by- bit basis between two operands. With operations requiring two operands, smaller microprocessors usually require that one of the operands must be in a destination register initially, while the other may be in another register or in memory. Their instructions may identify at most a single operand in memory, as shown in Figure 5.2a. They support such operations as adding or ANDing to processor registers as illustrated but not to memory locations.
modes. In part a the instruction specifies the address of the operand; in part b the instruction specifies the register containing the operand.
FIGURE 5.3 Direct addressing: (a) absolute addressing, (b) register direct addressing. (LDA 100BH, ADDA 100CH, STA 100DH
Direct addressing is used when the memory address or the selected register is to be fixed in the program.
In many cases an instruction requires a constant quantity, a bit pattern which will never change no matter when or how often the instruction is executed. This mode of including a bit pattern as a part of an instruction is called the immediate addressing mode. The op-word for the instruction includes a group of bits which identifies this mode of addressing, and the post-words include the bit pattern itself. Since the instruction is located in program memory the constant itself is also in program memory. The immediate addressing mode the instruction does not state explicitly the location of the operand; rather, it explicitly states the operand itself. The example in Figure 5.4 illustrates this mode. Note that the operand becomes an integral part of the instruction.
FIGURE 5.4 Immediate addressing.
Immediate addressing is used when a particular constant value is to be fixed within the program itself. The value is found in memory "immediately" after the instruction code word and may never change at any time.
In the indirect addressing mode the instruction tells the processor neither the address of the operand nor the operand itself. Instead, it tells the processor where to go to find the address of the operand. The instruction may explicitly state either the address of a location in memory or the name
of a processor register, but the binary number which is found there is not the operand. Instead, it is the effective address, the address of a location in memory to which the processor must go to find the operand. The result is that the processor must take one extra step in order to locate the operand. The op-word for the instruction includes a group of bits which identifies this mode of addressing, and the (indirect) address is specified in one or more additional post-words. If the instruction names a processor register as the source of the effective address, then the register identification number may fit into the op-word itself. Indirect addressing is used when a program must operate upon different data values under different circumstances. Figure 5.6 compares and contrasts the first three addressing modes. Note that in the immediate mode the instruction includes the operand, in the direct mode it includes the address of the operand, and in the indirect mode it includes the address of the address of the operand.
FIGURE 5.5 Indirect addressing: (a) memory indirect, (b) register indirect.
FIGURE 5.6 Comparison of immediate, direct, and indirect addressing.
Each of the following related addressing modes requires that the processor assemble two or more components together during the execution of the program in order to create the effective address. In each case the effective address itself is that of a memory location. However, at least one of the components is found in a processor register. Instructions which use indexed addressing specify two registers, often by coding within the op- word itself and known as "indexed addressing". During program execution the processor temporarily
FIGURE 5.8 (PC) Relative addressing.
Certain instructions allow no choice of register or location but always cause the processor to refer to the same registers. One example is the multiply instruction in the MC6809 which always assumes that the operands are in accumulators A and B. Examples in the MC6809 are ABX (add B to X), CLRA (clear A), and TSTA (test A).
3 THE MC6809 ADDRESSING MODES
This section describes in detail the addressing modes used in the Motorola MC6809 microprocessor, their formats within program memory, and how they are specified in mnemonic form. The terminology is that used in the manufacturer's literature. The MC6809 includes five addressing modes: extended, immediate, direct, relative, and indexed. In addition, the indexed mode has a large variety of options. Because of the large number of instructions and addressing modes, the instructions vary in length from one to five bytes. The basic addressing modes are illustrated in Figure 5.
FIGURE 5.10 MC6809 addressing modes: (a) extended, (b) immediate, (c) direct, (d) relative (branches only), (e) indexed.
While repeating a program loop the processor must often change a pointer to an adjacent address in memory on each pass through the loop. It may be necessary to increment or decrement the value in the pointer, depending upon the direction in which the array is being scanned. Two examples of auto increment/decrement options are shown in Figure 5.18. Part a is the instruction LDA ,X+, load A indexed with X post-inc by one. Figure 5.18b is the instruction STY ,- - U. When it is executed the processor will first decrement the index register U by 2. Following that, it will store the upper half of the two-byte register Y into the new location indicated by register U and the lower half into the next subsequent location.