DEBUG is a method of looking at portions of your computer and writing assembly code to perform certain tasks on your computer. MS-DOS 2.x - 4.x used DEBUG.COM and MS-DOS 5.x and beyond used DEBUG.EXE for this.
DEBUG.EXE is one of those little programs that, in the hands of a skilled user, is an amazingly powerful tool with which one can view and edit the contents of memory both short term(RAM) and long term (hard/floppy/tape media). One can also compile (and, up to a point, decompile) assembly language code.
DEBUG is a byte editor that enables files to be viewed and modified at the byte level. It is generally recommended as there is no "undo" command, so make a backup before playing with it. Be sure that you know what you are doing when using the DEBUG utility.
This is a powerful programmer’s tool that can be used to gain access to your computer at the hardware level. If you are not careful, you could cause such damage as erasing your hard disk or locking up your keyboard.
DEBUG [[drive:] [path] filename [testfile-parameters]]
[drive:][path]filename Specifies the file you want to test.
testfile-parameters Specifies command-line information required by the file you want to test.
How to start DEBUG
DEBUG can be started in one of two ways.
At the DOS prompt you enter
DEBUG will respond with the hyphen (-) prompt. When the prompt appears DEBUG is waiting for you to enter one of its 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.
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 are 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).
At the DOS prompt you enter
DEBUG \path\filename (return)
DEBUG will then load itself into memory along with the file that is specified in the path and filename 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.
MS-DOS will allow only two types of programs to run under its 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 program terminates.
Without going into a lot of details, we shall point out the major difference between these two types of programs.
COM programs are very small and compact programs that cannot be larger than 65K bytes in size. The PSP of a COM program is located in the first 100 Hex (256 Dec) locations of the program. The first instruction of the COM program must start at offset 100 in memory.
DOS creates the PSP for the COM program, which means we don't have to be concerned with this when we assemble a program. All the data, code, and the stack area are in the same segment of memory (1 segment is 64K).
|Sample Chapters from book DATA RECOVERY WITH AND WITHOUT PROGRAMMING by Author Tarun Tyagi
Publishers of the Book
Number of Pages
Price of the Book
BPB Publications, New Delhi, India
$69.00 (Including Shipping Charges, Cost of Book and Other expenses, Free Source Code CD included with the Book)