31-08-2012, 05:17 PM
Machine Language Coding and the DEBUG Software Development Program of the PC.
C Machine Language.doc (Size: 164.5 KB / Downloads: 30)
Introduction
In this chapter, we begin our study by exploring how the instructions of the 8088/8086 instruction set are encoded in machine code. This is followed by a study of the software development environment provided for these microprocessors with the PC compatible microcomputer. Here we examine the DEBUG program, which is a program execution/debug tool that operates in the IBM-compatible PC's disk operating system (DOS) environment. The topics discussed in this chapter are as follows:
Encoding a complete Program in Machine code
The PC and Its DEBUG Program
Examining and Modifying the Contents of Memory
Input and Output of Data
Hexadecimal Addition and Subtraction
Loading, Verifying, and Saving Machine Language Programs
Assembling Instructions with the Assemble Command
Executing Instructions and Programs with the TRACE and GO Commands
Debugging a Program
Converting Assembly Language Instructions to Machine Code
To convert an assembly language program to machine code, we must convert each assembly language instruction to its equivalent machine code instruction. In general, the machine code for an instruction specifies things like what operation is to be performed on byte or what operand or operands are to be used, whether the operation is performed on byte or word data, whether the operation involves operands that are located in registers or a register and a storage location in memory, and if one of the operands is in memory, how its address is to be generated. All of this information is encoded into the bits of the machine code for the instructions.
The machine code instructions of the 8088 vary in the number of the bytes used to encode them. Some instructions can be encoded with just one byte, others in two bytes and many require even more. The machine code for instructions can be obtained by following the formats used in encoding the instructions of the 8088 microprocessor. Most multibyte instructions use the general instruction format shown in fig. 4-1. From figure 4-1 we can see that byte 1 contains three kinds of information: the operation code (opcode), the register direction bit (D), and the data size bit (W). Below is the summary of the function of each of these pieces of information.
Encoding a Complete Program in Machine Code
To encode a complete assembly language program in machine code, we must individually encode each of its instructions. This can be done by using the instruction formats shown in fig. 3-6 in the text book and the information in the tables of fig. 4-2, 4-3, 4-4, and 4-5. We first identify the general machine code format for the instruction in fig. 3-6. After determining the format, the bit fields can be evaluated using the tables of fig. 4-2, 4-3, 4-4, and 4-5. Finally, the binary-coded instruction can be expressed in the hexadecimal form.
To execute a program on the PC, we must first store the machine code of the program in the code segment of the memory. The bytes of the machine code are stored in sequentially addressed locations in memory. The first byte of the program is stored at the lowest address, and it is followed by the other bytes in the order in which they are encoded. That is, the address is incremented by one after storing each byte of machine code in memory.
Refer text book Example 4.7 to learn more about encoding a program.
The PC and its Debug Program
Now that we know how to convert an assembly language program to machine code and how this machine code is stored in memory, we are ready to enter it into the PC; execute it; examine the results that it produces; and, if necessary, debug any errors in its operation. In this section you will study how to load the DEBUG program from DOS, how to use it to examine or modify the contents of the MPU's internal registers, and how to return to DOS from DEBUG. Using DEBUG, the programmer can issue commands to the microcomputer in the PC. Assuming that the DOS has already been loaded and that a disk that contains the DEBUG program is in drive A, DEBUG is loaded by simply issuing the command