Debug Commands
Debug Commands
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] [number]
unassemble U [range]
write W [address] [drive] [firstsector] [number]
address - Memory location specified in hexadecimal. You can use either a simple Offset all by itself
(in which case, the present CS 'Code Segment' will be assumed), or you can enter the full
Segment:Offset location using either all hex numbers or substituting the name of a segment register
for a number. Leading zeros are not required; thus 1F all by itself would be the location 'CS:001F' (
CS meaning whatever the CS happened to be at the time you entered this ).
Examples:
100 DS:12 SS:0 198A:1234
range - Two hexadecimal addresses separated by a single space. They may be listed as either full
Segment:Offset pairs or just an Offset alone ( in which case, the Segment is assumed to be that of the
present CS or "Code Segment" ). NOTE: Some commands, such as Compare (C), may require that
the second address be given only as an offset.
list - A string of Hexadecimal bytes separated by a space, or ASCII data enclosed within single or
double quote marks. You can list any number of bytes from a single one up whatever number fits on
the line before having to press the Enter key. A single byte, such as 00 is most often used with the
FILL (f) command whereas an ENTER (e) command will most likely have a string of many hex
bytes or ASCII characters per line; for example:
e 100 31 C0 B4 09 BA 50 02 CD 21 B8 4C 00 CD 21
e 250 'This is an ASCII data string.$'
number - Remember that all numbers and values used in any DEBUG commands are understood as
being Hexadecimal only! That includes the number of sectors in the LOAD or WRITE commands
and even the number of instructions you want DEBUG to step through in the TRACE or PROCEED
commands. It's all HEX all the time in here!
Help: ?
Displays a list of debug commands
Quit: Q
Immediately quits (exits) the Debug program! No questions ever asked... should be the first command you
remember along with the "?" command.
Example:
-d c000:0010
C000:0010 24 12 FF FF 00 00 00 00-60 00 00 00 00 20 49 42 $.......`.... IB
C000:0020 4D 20 43 4F 4D 50 41 54-49 42 4C 45 20 4D 41 54 M COMPATIBLE MAT
C000:0030 52 4F 58 2F 4D 47 41 2D-47 31 30 30 20 56 47 41 ROX/MGA-G100 VGA
C000:0040 2F 56 42 45 20 42 49 4F-53 20 28 56 31 2E 32 20 /VBE BIOS (V1.2
C000:0050 29 00 87 DB 87 DB 87 DB-87 DB 87 DB 87 DB 87 DB )...............
C000:0060 50 43 49 52 2B 10 01 10-00 00 18 00 00 00 00 03 PCIR+...........
C000:0070 40 00 12 10 00 80 00 00-38 37 34 2D 32 00 FF FF @.......874-2...
C000:0080 E8 26 56 8B D8 E8 C6 56-74 22 8C C8 3D 00 C0 74 .&V....Vt"..=..t
- Values in Hexadecimal Contents
The bytes at locations 140 through 148 are being compared to those at 340 (through 348, implied);
the bytes are displayed side by side for those which are different (with their exact locations,
including the segment, on either side of them).
Assemble: A [address]
Creates machine executable code in memory beginning at CS:0100 (or the specified address) from
the 8086/8088 (and 8087) Assembly Language instructions which are entered. Although no Macro
instructions nor labels are recognized, you can use the pseudo-instructions 'DB' and 'DW' (so you
can use the DB opcode to enter ASCII data like this: DB 'This is a string',0D,0A ).
The 'A' command remembers the last location where any data was assembled, so successive 'A'
commands (when no address is specified) will always begin at the next address in the chain of
assembled instructions. This aspect of the command is similar to the Dump command which
remembers the location of its last dump (if no new address is specified).
The assembly process will stop after you ENTER an empty line.
Unassemble: U [range]
Disassembles machine instructions into 8086 Assembly code. Without the optional [range], it
uses Offset 100 as its starting point, disassembles about 32 bytes and then remembers the next byte
it should start with if the command is used again. ( The word 'about' was used above, because it may
be necessary to finish with an odd-number of bytes greater than 32, depending upon the last type of
instruction DEBUG has to disassemble.
Example:
-u 126 133
xxxx:0126 31C0 XOR AX,AX
xxxx:0128 B409 MOV AH,09
xxxx:012A BA0201 MOV DX,0102
xxxx:012D CD21 INT 21
xxxx:012F B84C00 MOV AX,004C
xxxx:0132 CD21 INT 21
-
Register: R [register]
Entering ' r ' all by itself will display all of the 8086 register's contents and the next instruction
which the IP register points to in both machine code and an unassembled (Assembly Language)
form. For example, if you start DEBUG in a Windows 95B DOS-box with the command line:
>debug c:\windows\command\choice.com
and then enter an ' r ' at the first DEBUG prompt, DEBUG will display someting similar to this:
AX=0000 BX=0000 CX=1437 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000
DS=0ED8 ES=0ED8 SS=0ED8 CS=0ED8 IP=0100 NV UP EI PL NZ NA PO NC
0ED8:0100 E90E01 JMP 0211
Flags Register
Flag Name Set Clear
Overflow(yes/no) OV NV
Direction(increment/decrement) DN UP
Interrupt(enable/disable) EI DI
Sign(negative/positive) NG PL
Zero(yes/no) ZR NZ
Auxiliary carry(yes/no) AC NA
Parity(even/odd) PE PO
Carry(yes/no) CY NC
Load:
L [address] [drive] [firstsector] [number] or program! (See the N command for more on this)
This command will LOAD the selected number of sectors from any disk's Logical Drive under the control of
MS-DOS or Windows into Memory. The address is the location in Memory the data will be copied to (use
only 4 hex digits to keep it within the memory allocated to DEBUG), the drive number is mapped as: 0=A:,
1=B:, 2=C:, etc., firstsector counts from ZERO to the largest sector in the volume and
finally number specifies in hexadecimal the total number of sectors that will be copied into Memory (so a
floppy disk with 0 through 2,879 sectors would be: 0 through B3F in Hex).
You can follow the steps above to Assemble and save this program under DEBUG, then use DEBUG
to debug it!
Use the P(roceed) command to step through most of the instructions (INT for now), since this will keep you
from accidentally stepping into an INT(errupt) instruction! If you ever do use the T(race) command on an
INT, you'll end up inside nests of BIOS routines which often crashes DEBUG!
Write:
W [address] [drive] [firstsector] [number]
WARNING
Do NOT experiment with the W - write command in DEBUG. It can be used
effectively to create new files on your hard drive, but only if you use it properly.
Trying to write directly to a sector on a hard disk would very RARELY be
considered proper use of this command!
Trying to write directly to a hard disk using sector numbers will most likely result in loss
of data or even a corrupted hard drive!
The WRITE (W) command is often used to save a program to your hard disk from
within DEBUG. But the only safe way to do so, especially under Windows, is by
allowing the OS to decide where to physically create that file on the disk. This is done
by first using the Name (N) command to set up an optional path and filename for the
new file (or to overwrite one that already exists). DEBUG will automatically begin
saving program or data bytes from Offset 0100 of the 64 KiB Segment that the OS
allocated for it. The only other requirement is to set the size of the file you wish to
write by placing the total number of bytes in the combined BX and CX
registers* before executing the WRITE command. The Register command is used to
change the value in the CX register.