| DEBUG.COM (MS-DOS <= 2.0), DEBUG.EXE (MS-DOS >= 3.x) | |
|---|---|
| Original author | Tim Paterson |
| Developers | Microsoft,IBM,Digital Research,Novell,Caldera |
| Written in | MS-DOS:x86 assembly language |
| Operating system | DOS,OS/2,Windows |
| Type | Debugger |
| License | MS-DOS v2.0, FreeDOS:MIT OS/2, Windows:Proprietary software |
| Website | Debug |
The line-orienteddebuggerDEBUG.EXE is an external command inoperating systems such asDOS,OS/2 andWindows (only in 16-bit/32-bit versions[1]).
DEBUG can act as anassembler,disassembler, orhex dump program allowing users to interactively examinememory contents (inassembly language,hexadecimal orASCII), make changes, and selectively executeCOM,EXE and other file types. It also has several subcommands which are used to access specificdisk sectors,I/O ports andmemory addresses.

DEBUG.COM (among other commands) inIBM PC DOS 1.0.
DEBUG.EXE commandTraditionally, allcomputers andoperating systems have included a maintenance function, used to determine whether a program is working correctly.[citation needed] DEBUG was originally written byTim Paterson to serve this purpose in86-DOS. When Paterson began working for Microsoft in the early 1980s he brought the program with him. DEBUG was part ofDOS 1.00 and has been included inMS-DOS/PC DOS and certain versions ofMicrosoft Windows. Originally namedDEBUG.COM, the executable was renamed intoDEBUG.EXE with MS-DOS 3.2.[2]
Windows XP and later versions includedDEBUG for theMS-DOS subsystem to maintain MS-DOS compatibility. The 16-bit DOS commands are not available on64-bit editions of Windows.[3]
The MS-DOS/PC DOS DEBUG has several limitations:
Enhanced DEBUG packages include the DEBUG command inNovell DOS 7,OpenDOS 7.01 andDR-DOS 7.02 and higher, a reimplementation ofDigital Research's formerSymbolic Instruction Debugger SID/SID86,[4] which came with former versions ofDR DOS.[5][6][7] 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 thePentium, an extended mode (/X) with dozens of additional commands and sub-modes, a much enhanced command line syntax with user-definable macros andsymbolic debugging facilities with named registers, loadedsymbol tables, mathematical operations andbase conversions, as well as acommenting disassembler.[8][7] Some versions also utilizedDPMS to function as a "stealth mode" protected-mode debugger.[9]
TheFreeDOS version of DEBUG was developed by Paul Vojta and is licensed under theMIT License.[10]
A 32-bit clone "DEBUGX" version supporting32-bitDPMI programs exists as well.[11] Andreas "Japheth" Grech, the author of theHX DOS extender, developed enhanced DEBUG versions 0.98 to 1.25, and formerPC DOS developer Vernon C. Brooks added versions 1.26 to 1.32.[12]
DEBUG [[drive:][path] filename [parameters]]
When DEBUG is started without any parameters the DEBUG prompt, a "-" appears. The user can then enter one of several one or two-letter subcommands, including "A" to enter the assembler mode, "D" to perform ahexadecimal dump, "T" to trace and "U" to unassemble (disassemble) a program in memory.[13]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.[14] This method can be used to create or editbinary files frombatch files.[2]
The following is a list of the DEBUG commands available from DEBUG.EXE in MS-DOS 6.22 via the? command.
assemble A [address]compare C range addressdump D [range]enter E address [list]fill F range listgo G [=address] [addresses]hex H value1 value2input I portload L [address] [drive] [firstsector] [number]move M range addressname N [pathname] [arglist]output O port byteproceed P [=address] [number]quit Qregister R [register]search S range listtrace T [=address] [value]unassemble U [range]write W [address] [drive] [firstsector] [number]allocate expanded memory XA [#pages]deallocate expanded memory XD [handle]map expanded memory pages XM [Lpage] [Ppage] [handle]display expanded memory status XS
The R command displays the current register status and values
AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=2A63 ES=2A63 SS=2A63 CS=2A63 IP=0100 NV UP EI PL NZ NA PO NC2A63:0100 0F DB 0F
While D dumps the current memory displaying both hexadecimal and ASCII values
2A63:0100 0F 00 B9 8A FF F3 AE 47-61 03 1F 8B C3 48 12 B1 .......Ga....H..2A63:0110 04 8B C6 F7 0A 0A D0 D3-48 DA 2B D0 34 00 52 2A ........H.+.4.R\*2A63:0120 00 DB D2 D3 E0 03 F0 8E-DA 8B C7 16 C2 B6 01 16 ................2A63:0130 C0 16 F8 8E C2 AC 8A D0-00 00 4E AD 8B C8 46 8A ..........N...F.2A63:0140 C2 24 FE 3C B0 75 05 AC-F3 AA A0 0A EB 06 3C B2 .$.<.u........<.2A63:0150 75 6D 6D 13 A8 01 50 14-74 B1 BE 32 01 8D 8B 1E umm...P.t..2....2A63:0160 8E FC 12 A8 33 D2 29 E3-13 8B C2 03 C3 69 02 00 ....3.)......i..2A63:0170 0B F8 83 FF FF 74 11 26-01 1D E2 F3 81 00 94 FA .....t.&........
AndUnassemble displays the attempted disassembly of the same memory
2A63:0100 0F DB 0F 2A63:0101 00B98AFF ADD [BX+DI+FF8A],BH 2A63:0105 F3 REPZ 2A63:0106 AE SCASB 2A63:0107 47 INC DI 2A63:0108 61 DB 61 2A63:0109 031F ADD BX,[BX] 2A63:010B 8BC3 MOV AX,BX 2A63:010D 48 DEC AX 2A63:010E 12B1048B ADC DH,[BX+DI+8B04] 2A63:0112 C6F70A MOV BH,0A 2A63:0115 0AD0 OR DL,AL 2A63:0117 D348DA ROR WORD PTR [BX+SI-26],CL 2A63:011A 2BD0 SUB DX,AX 2A63:011C 3400 XOR AL,00 2A63:011E 52 PUSH DX 2A63:011F 2A00 SUB AL,[BX+SI]
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.
Although technical documentation for the DEBUG command was removed with the release of MS-DOS 3.3, the command was retained in the standard distribution, unlike what was done withEXE2BIN.[15]
Theoperating systemsIntelISIS-II[16] andiRMX 86,[17]DECTOPS-10[18] andTOPS-20,[19]THEOS/OASIS,[20]ZilogZ80-RIO,[21]StratusOpenVOS,[22]PC-MOS,[23] andAROS[24] also provide aDEBUG command.
{{cite book}}:|work= ignored (help) (NB. Has some information on Symbolic Instruction Debugger (SID86.EXE inDR DOS 3.41 and SID.EXE in DR DOS 5.0/6.0), the predecessor of the DR-DOS DEBUG.EXE.)[…] Since theDR-DOS 7.03 DEBUG is still based on the old SID86.EXE, I suggest to run DEBUG 1.51 and enter the extended help system with ?? from the debug prompt. This will give you eight screens full of syntax and feature help. Some of these features were also supported by older issues. […]
{{cite book}}:|work= ignored (help) (NB. NWDOSTIP.TXT is a comprehensive work onNovell DOS 7 andOpenDOS 7.01, including the description of many undocumented features and internals. It is part of the author's yet larger MPDOSTIP.ZIP collection maintained up to 2001 and distributed on many sites at the time. The provided link points to a HTML-converted older version of the NWDOSTIP.TXT file.){{cite book}}:|work= ignored (help)