Chapter 2
To avoid a lot of confusion when you work with the debug program, the 8088 CPU instruction set and assembly programming, refer to the following list showing the commands and instructions of each one.
Debug commands
A C D E F G H I L M N O P Q R S T U W ?
8088 Instructions
The microprocessor is a digital circuit that only responses to a series of one's and zero's. Data is input to the CPU on the data pins marked D0 - D7. This is equal to one byte or 8 bits. If the first byte of data that enters the processor is an instruction, the processor will respond by performing the proper operation. In other words, the CPU has a set of 8 bit or one byte codes that it response's to, that will cause an operation to take place inside the registers or on the buses of the system board. These codes are called instructions and all of the codes combined are referred to has the instruction set.
The following examples of several 8088 instructions will help you understand. These are real instructions that preform the specified operation.
Byte D7--D0------------operation performed
1. 10111000 ----moves the next two bytes into AX
2. 00000101 ----LSB of the number (goes in al)
3. 00000000 ----MSB of the number (goes in ah)
4. 00000001 ----adds BX to AX- result goes in BX
5. 10001001 ----moves the contents of BX to the
6. 00011110 ----memory location pointed to by
7. 00100000 ----the next two bytes.
8. 00000001
There are 256 possible combinations of an 8 bit binary number that can be used as an instruction. It is virtually impossible for a human being to remember and work with all of these one's and zero's of the 8088 instruction set. It has become necessary for us to represent these binary numbers with the base 16 number system.(Hex) The Hex representation of binary does make it a little easier to work with. For example, the program listed above in machine code (1's and 0's) can be represented with the Hex digits for the instructions as shown below.
Byte # D7-D0-----------------------------------operation performed
1. B8 --------------------------------moves the next two bytes into AX
2. 05 --------------------------------LSB of the number (goes in al)
3. 00 --------------------------------MSB of the number (goes in ah)
4. 01 --------------------------------adds BX to AX- result goes in BX
5. 89 --------------------------------moves the contents of BX to the
6. 1E --------------------------------memory location pointed to by
7. 20 --------------------------------the next two bytes.
8. 01
This kind of programming is called machine code because the instructions are entered using binary or Hex data which, is the real data the CPU is responding to. The complete set of machine instructions will not be listed here because it would serve no purpose at this time. If you find a need for this information you must refer to the INTEL 8088 technical manual.
Assembly language
----------------------
Programming in the early days of computing had to be written using the machine code of the microprocessor and as a result required specialized people who had this ability. The use of computers was restricted to the companies and corporations with the finances to support such a specialized operation. It didn't take long for the programmers to write the code to do most of the hard work in binary. One of the most important programs written was the Assembler, which was a conversion type program that allowed the use of English words to represent the instruction set of the CPU, that was compiled into machine code after they were written. One such program is Debug.com that is supplied by the MicroSoft corp. in most versions of DOS.
Debug, which is a small but powerful assembler, converts English sounding words called mnemonics into the machine code. All instructions for the 8088 have a mnemonic word to represent them in debug. For example, in the program above, the code can be written in an assembler language that is much easier to write and understand.
The mnemonic form of that program is shown below.
mnemonic form----------machine code
MOV AX,0005------------B80500
ADD BX,AX---------------01C3
MOV [120],AX------------891E2001
Debug Command Description
-----------------------------------------
A- Assembles 8086/8088 mnemonics.
C- Compares two areas of memory.
D- Displays the contents of memory locations.
E- Enters data into specified memory locations.
F- Fills memory locations with specified values.
G- Runs an executable program from within debug.
H- Performs Hexadecimal math on two Hex numbers.
i- reads one byte of data from the specified port.
L- loads the contents of a disk file or sectors into memory.
M- moves or copies the contents of memory locations.
N- Names a file for the L or w command. (load or write)
O- outputs one byte of data to the specified port.
P- Executes a loop, a repeated string instruction, a software interrupt, or a subroutine.
Q- Quits a debug session.
R- Displays or modifies the contents of the cpu registers.
S- Searches the contents of memory for the specified string of data.
T- Executes one instruction at a time and dumps the contents of all the registers to the screen, then displays the next instruction to be executed.
U- Disassembles machine code into the mnemonic form of the program.
W- Writes the data in memory to the disk. The name given the file is the name entered with the n (name) command. The file size is given by setting the BX:CX register to the number of bytes to be saved.
?- Display a help screen on some versions of debug.
A (assemble) Assembles 8088/8086 mnemonics into memory. This command is used to create executable machine code from assembly-language statements. All numeric values are in hexadecimal form and can only have from 1 to 4 digits.
SYNTAX - A [address]
PARAMETER
address - the location where you will store the assembly-language instruction. The address must be in Hexadecimal form and within the range of 0100-FFFF. If you don't specify an address, debug will default to the last address used.
An assembly-language instruction is made up of a mnemonic instruction word followed by none/one or two operands. The format of an instruction is shown below.
MNEMONIC 1st parameter, 2nd parameter
--------------------------------------
----------(destination) (source)
op-code 1st operand, 2nd operand
MOV AX , BX
The op-code part of the instruction (MOV) tells the processor what to do.
The 1st parameter (AX) is the 1st location of data that the operation will be performed on.
The 2nd parameter (BX) is the second location of data that the operation will be performed on.
These parameters are called operands.
The 1st operand is the destination of the data, the second operand is the source of data.
In other words data moves from the second operand to the first operand.
The above move instruction above will move the contents of the BX register into the AX register.
More examples:
MOV AX,45 load the hex number 45 into the AX register
MOV AX,[120] load the contents of location 120 into the AX register
ADD AX,[500] add contents of location 500 to AX ,save the results into AX
Note: You must start assembly of a COM program at offset 100.
C (compare) Compares two blocks of memory.
SYNTAX C range address
PARAMETERS
range - specifies the starting and ending addresses or the start address and length, of the first block of memory to compare.
address - specifies the starting address of the second block of memory you want to compare.
Example:
C 100 220 500
compares the block of memory at offset 100 - 220 with the block starting at offset 500.
C 100 L 120 500
compares the block of memory at offset 100 for a length of 120 to the block of memory starting at 500.
D (dump)
Displays or dumps the contents of memory onto the display.
SYNTAX D [range]
PARAMETER
range - specifies the starting and ending address or the starting address and the length, of memory to be displayed. If you don't specify a range debug will display 128 bytes starting at the end of the last address dumped.
Note: When you use the D command, debug displays memory contents in two portions: a hexadecimal (each byte value is shown in hex form) and an ASCII portion (each byte shown as an ascii character).