DEBUG/ASSEMBLY TUTORIAL by Fran Golden



Chapter 1


This is a debug tutorial to assist the student who needs to know the inner-workings of the Intel based computer. The objective of this material is to instruct the student in observing the contents of the microprocessor and all of the memory locations that the processor can address. After you become familiar with debug and how it looks at addresses, You will be introduced to machine level programming, using debug as an assembler. At the end of this tutorial you should have a good understanding of the IBM system board and low level programming. Debug is a small utility program that uses one letter commands followed by several parameters needed on the command line.

It may be helpful if you have debug up and running as you read this tutorial so that the commands discussed can be entered and tested as you proceed through the material. Change the directory to the directory that has Debug.com and enter the command "Debug". Debug will load into memory and display the debug prompt, which is the hyphen "-". When you see the hyphen, debug is waiting for you to enter any one of the one letter commands.

The following pages show all of the commands and the syntax used with each. A detailed explanation of each command will help you in the proper usage and meaning.

How to start debug
-------------------

Debug can be started in one of two ways.

Method one:

At the DOS prompt you enter

DEBUG (return)

Debug will respond with the hyphen (-) prompt. When the prompt appears debug is waiting for you to enter one of it's many one letter commands. Starting debug this way will allow you to work on the internal hardware of the computer and view the contents of all of the memory location in RAM. You can also load in as many as 128 sectors of a floppy or Hard disk and view, edit or move the contents to another location.(see L command)

At the end of this tutorial you will be able to do the following tasks by starting debug this way.

1. Look at the DOS data area in memory to determine what kind of equipment is installed on the mother board.
2. Look at the internal workings of DOS at such things as the keyboard buffer, real time clock, interrupt vector table, rom bios chip and the video ram chips to name a few.
3. Recover deleted files from a floppy or hard disk.
4. Recover data from a disk that is un-readable by DOS and is otherwise lost.
5. Do diagnostic's on some of the hardware, such as, video display, printers, disk drives and chips.
6. Low level format a hard-drive
7. Finally, you can assemble small COM programs using the 8088 instruction set.

Note:
Debug sets up a work area in memory of 65,535 (decimal) one byte locations which is equal to FFFF bytes in Hex. The first 256 (decimal) or 100 Hex bytes of this area is set aside for what is called the Program Segment Prefix (PSP) of a program and must not be altered in any way. Whenever We load sectors or data in memory with debug, it must be put at a location starting at offset 100.
An example of a debug command is shown on the following line.
L 0100 0 0 80 (return)
In this command, We are telling debug to load into memory starting at offset 100, 80 (Hex) sectors from the A drive starting with sector 0. 80 Hex sectors is equal to 128 decimal sectors, so if each sector on the disk, stores 512 bytes then the total number of bytes loaded into memory is (512 X 128) or 65,540 bytes. (maximum). We will go into more detail in the following sections.

Method Two:

At the DOS prompt you enter

Debug \path\filespec (return)

Debug will then load itself into memory along with the file that is specified in the path\filespec field of the command line and put the first byte of the file at offset 100 of the work area. By starting debug this way, We are able to view, edit or move a COM program or an Ascii text file. This is a very convenient way to debug or fix a COM program that was written with debug at some other time.

Note:
MS-DOS will allow only two types of programs to run under it's control and they must end with the extensions of EXE or COM. The difference in these two program types is in the way DOS handles the maintenance portions of the program. This maintenance area, often called the Program Segment Prefix (PSP), is a 256 byte block of memory that must be set aside by the program and is needed by DOS to return control back to the operating system when the the program terminates.
Without going into a lot of detail at this time, I will point out the major difference between these two types of programs.

COM Extensions

1. COM programs are very small and compact programs that cannot be larger than 65K bytes in size.
2. The PSP of a COM program is located in the first 100 Hex (256 Dec) locations of the program.
3. The first instruction of the COM program must start at offset 100 in memory.
4. DOS creates the PSP for the COM program, which means we don't have to be concerned with this when we assemble a program.
5. All the data, code, and the stack area are in the same segment of memory. (1 segment is 65K)
EXE Extensions

1. The EXE programs can be any size from (200 bytes-640k bytes)
2. The PSP must be setup by the programmer, when the program is assembled.
3. The programmer determines where the first instruction is in the program.
4. The EXE program uses separate segments for the data, code and stack area in memory.
From the above comparison you can see it is much more difficult to assemble an EXE program than it is a COM program. The debug utility program was designed to work only with a COM program by setting up the PSP area each time we enter debug. Once in debug, we can start assembly of a program at offset 100 and not be concerned with PSP or where the data, code, and stack is located. It is possible to look at an EXE program with debug if we rename the program with a different extension before we load it into memory.

  • Chapter 2
  • Return to Home Page.