24-01-2013, 04:44 PM
Programming – Integer Instructions and Computations
1Programming.doc (Size: 364 KB / Downloads: 61)
Introduction
Up to this point we have studied the software architecture of the 8088 and 8086 microprocessors, their instruction set, addressing modes, and the software development tools provided by the DEBUG program of DOS. We found that the software architectures of the 8088 and 8086 microprocessors are identical and learned how to encode assembly language instructions in machine language and how to use the debugger to enter, execute, and debug programs. In this chapter, we begin a detailed study of the instruction set of the 8088 and 8086 microprocessors. The instructions provide the ability to write simple programs. The following topics are presented in this chapter:
Data-Transfer instructions
Arithmetic instructions
Logic Instructions
Shift Instructions
Rotate Instructions
Data Transfer Instructions
The 8088 microprocessor has a group of data –transfer instructions that are provided to move data either between its internal registers or between an internal register and a storage location in memory. This group includes the move byte or word (MOV) instruction, exchange byte or word (XCHG) instruction, translate byte (XLAT) instruction, load effective address (LEA) instruction, load data segment (LDS) instruction, and load extra segment (LES) instruction.
The MOV Instruction
The move instruction was briefly introduced in Section 3.4 and used in Section 3.5 to demonstrate the addressing modes of the processor. The move (MOV) instruction shown in Fig. 5 –1 (a) is used to transfer a byte or a word of data from a source operand to a destination operand. Earlier we had found that the operands can be internal registers of the 8088 and storage locations in memory.
Figure 5-1(b) shows the valid source and destination operand variations. MOV instruction cannot transfer data directly between a source and destination, which both reside in external memory. Instead, the data must first be moved from memory into an internal register, with one MOV instruction and then moved to the new location in memory with a second MOV instruction. All transfers between general-purpose registers and memory can involve either a byte or word of data. The fact that the instruction corresponds to byte or word data is designated by the way in which its operands are specified. For instance, AL or AH would be used to specify a byte operand, and AX, a word operand. On the other hand, data moved between one of the general-purpose registers and a segment register or between a segment register and a memory location must always be word-wide.
The XCHG Instruction
In our study of the move instruction, we found that it could be used to copy the contents of a register or a memory location into another register or contents of a register into a storage location in memory. In all of these cases, original contents of the source location are preserved and the original contents of the destination location are destroyed. In some applications we need to exchange the contents of two registers. This could be done by using multiple move instructions and storage of the data in a temporary register. However to perform the exchange function more efficiently, a special instruction, the exchange (XCHG) instruction has been provided in the instruction set of 8088.
The XLAT Instruction
The translate (XLAT) instruction has been provided in the instruction set of the 8088 to simplify implementation of the lookup-table operation. This instruction is described in the following figure. When using XLAT, the contents of the register BX represent the offset of the starting address of the lookup-table from the beginning of the current data segment. Also, the contents of AL represent the offset of the element to be accessed from the beginning of the lookup-table. This 8- bit element address permits a table with up to 256 elements. The values in both of these registers must be initialized prior to execution of the XLAT instruction
Arithmetic Instructions
The instruction set of the 8088 microprocessor contains a variety of arithmetic instructions. They include instructions for the addition, subtraction, multiplication and division operations. These operations can be performed on numbers expressed in a variety of numeric data formats.
The status that results from the execution of an arithmetic instruction is recorded in the flags of the microprocessor. The flags that are affected by the arithmetic instructions are carry flag (CF), auxiliary flag (AF), sign flag (SF), zero flag (ZF), parity flag (PF), and overflow flag (OF).