Debug (command)


The line-oriented debugger DEBUG is an external command in operating systems such as DOS, OS/2 and Windows.
DEBUG can act as an assembler, disassembler, or hex dump program allowing users to interactively examine memory contents, make changes, and selectively execute COM, EXE and other file types. It also has several subcommands which are used to access specific disk sectors, I/O ports and memory addresses.

Overview

Traditionally, all computers and operating systems have included a maintenance function, used to determine whether a program is working correctly. DEBUG was originally written by Tim Paterson to serve this purpose in 86-DOS. When Paterson began working for Microsoft in the early 1980s he brought the program with him. DEBUG was part of and has been included in MS-DOS/PC DOS and certain versions of Microsoft Windows. Originally named DEBUG.COM, the executable was renamed into DEBUG.EXE with DOS 5.0.
Windows XP and later versions included DEBUG for the MS-DOS subsystem to maintain MS-DOS compatibility. The 16-bit DOS commands are not available on 64-bit editions of Windows.
The MS-DOS/PC DOS DEBUG has several limitations:
Enhanced DEBUG packages include the DEBUG command in Novell DOS 7, OpenDOS 7.01 and DR-DOS 7.02 and higher, a reimplementation of Digital Research's former Symbolic Instruction Debugger SID/SID86, which came with former versions of DR DOS. It is fully compatible with the DEBUG command line syntax of MS-DOS/PC DOS, but offers many enhancements, including supporting 16-bit and 32-bit opcodes up to the Pentium, an extended mode with dozens of additional commands and sub-modes, a much enhanced command line syntax with user-definable macros and symbolic debugging facilities with named registers, loaded symbol tables, mathematical operations and base conversions, as well as a commenting disassembler. Some versions also utilized DPMS to function as a "stealth mode" protected-mode debugger.
The FreeDOS version of DEBUG was developed by Paul Vojta.
A 32-bit clone "DEBUGX" version supporting 32-bit DPMI programs exists as well. Andreas "Japheth" Grech, the author of the HX DOS extender, developed enhanced DEBUG versions 0.98 to 1.25, and former PC DOS developer Vernon C. Brooks added versions 1.26 to 1.32.

Syntax

DEBUG drive:] filename hexadecimal dump, "T" to trace and "U" to unassemble a program in memory.
DEBUG can also be used as a "DEBUG script" interpreter using the following syntax.
DEBUG < filename
A [script file">hex dump">hexadecimal dump, "T" to trace and "U" to unassemble a program in memory.
DEBUG can also be used as a "DEBUG script" interpreter using the following syntax.
DEBUG < filename
A [script file may contain DEBUG subcommands and assembly language instructions. This method can be used to create or edit binary files from batch files.

Using for non-debugging purposes

The DEBUG utility is useful for editing binary files in an environment where only DOS is installed without anything else. It can also be used to edit disk sectors, which is one method of removing boot-sector viruses.

DEBUG in other operating systems

The operating systems Intel ISIS-II and iRMX 86, DEC TOPS-10 and TOPS-20, THEOS/OASIS, Zilog Z80-RIO, Stratus OpenVOS, PC-MOS, and AROS also provide a DEBUG command.