Debug (command)

Line-oriented debug utility in DOS


title: "Debug (command)" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["assemblers", "debuggers", "disassemblers", "external-dos-commands", "microsoft-free-software", "os/2-commands"] description: "Line-oriented debug utility in DOS" topic_path: "general/assemblers" source: "https://en.wikipedia.org/wiki/Debug_(command)" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

::summary Line-oriented debug utility in DOS ::

::data[format=table title="Infobox software"]

FieldValue
nameDEBUG.COM (MS-DOS = 3.x)
screenshotFile:Dosbox 001.png
authorTim Paterson
developerMicrosoft, IBM, Digital Research, Novell, Caldera
programming languageMS-DOS: x86 assembly language
operating systemDOS, OS/2, Windows
genreDebugger
licenseMS-DOS v2.0, FreeDOS: MIT
OS/2, Windows: Proprietary software
website
::

| name = DEBUG.COM (MS-DOS = 3.x) | screenshot = File:Dosbox 001.png | author = Tim Paterson | developer = Microsoft, IBM, Digital Research, Novell, Caldera | programming language = MS-DOS: x86 assembly language | operating system = DOS, OS/2, Windows | genre = Debugger | license = MS-DOS v2.0, FreeDOS: MIT OS/2, Windows: Proprietary software | website = The line-oriented debugger DEBUG.EXE is an external command in operating systems such as DOS, OS/2 and Windows (only in 16-bit/32-bit versions).

DEBUG can act as an assembler, disassembler, or hex dump program allowing users to interactively examine memory contents (in assembly language, hexadecimal or ASCII), 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

::figure[src="https://upload.wikimedia.org/wikipedia/commons/a/ac/IBM_PC_DOS_1.0_screenshot.png" caption="DEBUG.COM (among other commands) in [[IBM PC DOS]] 1.0."] ::

::figure[src="https://upload.wikimedia.org/wikipedia/commons/5/53/Microsoft_Windows_95_Version_4.00.1111_debug_command_492x259.png" caption="The [[Microsoft Windows 95]] DEBUG.EXE command"] ::

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 DOS 1.00 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 MS-DOS 3.2.

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 (/X) 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 and is licensed under the MIT License.

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:][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 a hexadecimal dump, "T" to trace and "U" to unassemble (disassemble) a program in memory. DEBUG can also be used as a "DEBUG script" interpreter using the following syntax.

DEBUG

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.

Debugging Subcommands

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 address dump         D [range] enter        E address [list] fill         F range list go           G [=address] [addresses] hex          H value1 value2 input        I port load         L [address] [drive] [firstsector] [number] move         M range address name         N [pathname] [arglist] output       O port byte proceed      P [=address] [number] quit         Q register     R [register] search       S range list trace        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 NC 2A63: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 .$. 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.&........ And 'U'''''nassemble 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]

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.

Availability

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 with EXE2BIN.

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.

References

References

  1. "A Guide to DEBUG".
  2. According to [http://msdn.microsoft.com/en-us/library/hb5z4sxd.aspx Microsoft Macro Assembler Reference], inline assembly is not supported for x64.
  3. [https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490895(v%3dtechnet.10) MS-DOS subsystem commands]
  4. "Microsoft TechNet Debug article".
  5. (1993). "DOS 6 Tuning". [[Markt & Technik]].
  6. (1997-05-24). "DRDOSTIP.TXT — Tips und Tricks für DR DOS 3.41 - 5.0". MPDOSTIP.
  7. (1997-07-30). "NWDOS-TIPs — Tips & Tricks rund um Novell DOS 7, mit Blick auf undokumentierte Details, Bugs und Workarounds". MPDOSTIP.
  8. (2001-04-09). "NWDOS-TIPs — Tips & Tricks rund um Novell DOS 7, mit Blick auf undokumentierte Details, Bugs und Workarounds". MPDOSTIP.
  9. (2002-01-09). "SID86".
  10. "DEBUG README".
  11. (2021-02-16). "FreeDOS 1.2 Updates Package - debug (FreeDOS Base)". Ibiblio.org.
  12. (2014-04-08). "Enhanced DEBUG for PC DOS and MS-DOS". PC DOS Retro.
  13. (2010). "Assembly language for Intel-based computers". [[Prentice Hall]].
  14. [http://bitsavers.org/pdf/intel/ISIS_II/9800306-06_ISIS-II_Users_Guide_May81.pdf ISIS II Users Guide]
  15. [https://archive.org/details/bitsavers_inteliRMX1_19819263 iRMX 86 Introduction And Operator's Reference Manual For Release 6]
  16. (August 1980). "TOPS-10 Operating System Commands Manual". Digital Equipment Corporation.
  17. "TOPS-20 Command manual".
  18. [http://www.bitsavers.org/pdf/phaseOneSystems/THEOS_OASIS_Users_Handbook_1985.pdf THEOS/OASIS User′s Handbook]
  19. "Z80-RIO Operating System User's Manual".
  20. "OpenVOS Commands Reference Manual".
  21. [https://github.com/roelandjansen/pcmos386v501/blob/master/DOCS/v4/PCMOSv4UserManual.pdf PC-MOS User Guide]
  22. "AROS Research Operating System".
  23. (August 1982). "SID-86 User's Guide for CP/M-86". [[Digital Research]].
  24. (1988-01-12). "Thank You, IBM".

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

assemblersdebuggersdisassemblersexternal-dos-commandsmicrosoft-free-softwareos/2-commands