The debugger.
      Debug [[drive:][path]file.ext [testprog arguments]]
This is a relatively advanced DOS tool but has many uses. For instance, it can be used to:


   The name of the executable you wish to debug.
   It doesn't have to be an executable - it could be a
   binary or text file.
   Since it can be any file, the file extension has to be specified.

   testprog arguments
   These arguments will be passed to the executable that is being
   debugged as command line options, if and when it is run.
   See Program Execution below for more information on running

Once Debug is started, the Debug command prompt is displayed. Enter Q to quit Debug, and ? to display the list of Debug commands.

General notes on Debug

Debug uses hexadecimal (base 16).

Memory addresses are displayed in segment:offset form, e.g. 0D00:0100. The last four hexadecimal digits, which specify the offset from the segment, can go from 0000 to FFFF, a range of 64 Kilobytes.

Executables with the .com extenstion have all their data and code in one segment. Hence for .com files, you can usually just write the offset when specifying memory addresses in Debug commands. Debug will assume the program segment. The same is also true of text/binary files that are <64K long.

To specify a memory range, seperate two addresses with a comma.

Differences between FreeDOS Debug and other versions

For those who have used Debug before but are migrating from a different version of DOS, the following document has been prepared: debug.doc

Debug's commands



Inspecting and Editing Memory

  C range address

  Compares two memory ranges, displaying the differences.
  Only the starting address of the second range is required, Debug will
  assume the second range will be the same size as the first.
  For instance
       C 100,110 200
  will compare the range 100,110 to 200,210.

  D [range]

  Displays the contents of a memory range. If no range is specified, dump
  will display 128 bytes, starting where the last dump finished or at the
  beginning of the loaded file.

  E address [list]

  Write over part of memory, beginning at address, with the list of bytes.
  To enter a string of text characters, enclose the text in double quotes.
  For instance
       E 100 "Hello!"

  F range list

  Write over a memory range with a repeating list of bytes. For instance,
  to set a memory range to zero, you might put
       E 100,110 0
  and to set a memory range to "brumbrum":
       E 100,107 "brum"

  M sourcerange destaddress

  Copies the range sourcerange into another range that begins at

  S range list

  Searches for all occurences of the list of bytes in the specified range.
  The starting address of each occurence is displayed.

Calculating Numbers in Hexadecimal

  H value1 value2

  Displays two numbers, the first being value1+value2, the second being

Loading and Saving Files

load program or file
  L [[drive:][path]progname [arglist]]

Set Name
  N [[drive:][path]progname [arglist]]

  Set the name for the current file/prgoram

Write program or file

  Writes the current program/file to disk. Use N to change the name
  if you do not wish to overwrite the original file.

Assembling and Disassembling

  A [address]

  U [range]

80x86 mode

  Sets the CPU (processor) mode: the setting is in the range 1-6.
  1 is for 80186, 2 for 80286 etc.
  If no setting is specified, the current setting is displayed
  This setting is reset when Debug quits.

FPU mode
  Sets whether the floating point maths coprocessor is present or not.
  Use MC to set it to present, MNC to set it to present.
  Use M to enquire about the current setting.

Program Execution

  G [=address] [breakpoints]

  Begins execution of the loaded program or the machine code
  at the specified address.
  Execution is suspended at the breakpoint addresses, allowing you
  to inspect memory etc.

  P [=address] [count]

  Proceeds with execution in steps.

  R [register [value]]
  display all CPU registers, or display/set a particular register.

  T [=address] [count]

Port I/O

  I port

  O port byte

Copyright © 2003 Rob Platt
This file forms part of The FreeDOS HTML Help Documentation, and is covered under its terms: see index.htm