Chapter 3

port - specifies the port address. The port address can be an 8 or a 16 bit value. It is possible to have up to 65,535 port addresses.(FFFF)

See port

If you type

i 3bc

debug will display 1 byte of data from the parallel port.

L (Load) loads a file or the contents of the specified sector from the disk into memory.

SYNTAX L address

L address drive start number

address - Specifies the memory location where you want to load the file or sector contents. If you don't specify an address, debug will use the address in the CS:IP registers

drive - specifies the drive that contains the disk that specific sectors are to be read. This is a number from 0 - 4.
0 = A
1 = B
2 = C
3 = D

start - specifies the hexadecimal number of the first sector whose contents you want to read.

number - specifies the hexadecimal number of sectors you want to load.

Using L with no parameters.

If you enter L without parameters, debug will re-load the file that was specified on the DEBUG command line into memory at offset CS:0100. Debug also sets the BX:CX registers to the number of bytes for the file size. If you didn't enter a file name on the command line debug will load the file that was specified by the n command.

The name of the file debug is using will be stored at offset 0080. To see the current name, use the d command to dump offset 80. Enter d 80 and debug displays the name of the current file. You should get in the habit of doing this so the file or program you are working on will be sure to get saved to the disk.

Using L with the address parameter

If you use L with just an address parameter, debug will load the data at the specified offset in memory.

Using L with all parameters
If you use all parameters, debug will load the specified sectors into the specified offset.

Loading an EXE program.
Debug ignores the address parameter for EXE files. If you specify an EXE file, debug relocates the file to the loading address specified in the header of the EXE file. The header itself is stripped off the EXE file before it is loaded into memory, so the file size on the disk will be different than the file size in memory. If you want to examine an EXE file, rename it with a different extension.


Example: Suppose you start debug and at the prompt you type,


You can then enter L and debug will load the file with the name you specified from the disk.

Suppose you want to load the root directory from the disk in the A drive. The root directory starts at sector number 5 and is a total of 7 sectors in size.

You enter,

L 0100 0 5 7

debug loads in the 7 sector starting at sector 5 from the disk in the A drive and stores it at offset 0100.

m (move)
Copies the contents of a block of memory to another block of memory.

SYNTAX m range address
range - specifies the starting and ending addresses, or the start and length of the memory area whose contents are to be copied.

address - specifies the starting address of the location where you want to copy the contents of range.


If you type the following command,

m 0100 110 500

Debug copies the block of data that starts at offset 100 and ends at offset 110, to offset 500 in memory.

You can use this command if you have to insert an instruction in the program that has already been written. Suppose you have to insert the instruction Mov ax,5600 in the program you are working on at offset 160.


m 160 FFFF 1000

Then assemble the instruction at offset 160.

A 160

CS:0160 MOV AX,5600 (return)

To get the rest of the program back together (it was moved to offset 1000)

m 1000 FFFF 163 (163 is the next offset

after MOV AX,5600)

The program should all be in order now.

n (name)
Specifies the name of a file that will be used by the L or the W command.


n [drive:][path]\filename

[drive:][path]filename - specifies the location and name of the file you want to work with.

Suppose you started debug with no filename on the command line, at the debug prompt you just enter the filename you want.


Then enter L and the file is loaded into memory.

Suppose you are working on a program and you want to work on a different program, just enter,

-n filename.ext

L (return)
and the new file is loaded into memory.

o (output)- sends one byte to the specified port.

SYNTAX o port byte

port - specifies the output port address. Can be an 8 or a 16 bit port.

Byte - specifies the hexadecimal that will be sent to the specified port.


To send the letter A to the parallel printer, Just enter,

o 3bc 41

See port

p (proceed)
Executes a loop, a repeated string instruction, a software interrupt, or a subroutine, or traces through any other instruction.

SYNTAX p [=address] [number]

address - specifies the address of the first instruction to be executed. If you don't specify an address, debug will use the address in the CS:IP registers. (see G command)

number - specifies the number of instruction to execute before returning control to debug. The default is one.

p is similar to g or the t command and is used for debugging a program by single stepping through the program. The p command however, will execute loops and INT instructions. The p command cannot be used to trace through the ROM bios program.

Q (quit) Exits debug and returns control to DOS.



Be sure to write your program or data to the disk before you enter Q, otherwise it will be lost.

R (register) displays or changes the contents of one or more of the micro-processor registers.

SYNTAX r [register-name]

r by itself will display all of the registers

rf displays the flag register

PARAMETER register-name - specifies the name of the register you want to display.

Using the r command
If you specify a register name, debug displays the 16 bit value of that register in hexadecimal form followed by the colon. If you want to change the value of the register, type the new value plus enter. If you don't want to change the value just press the enter key.

Valid register names

The following are valid register names.

Using the F character (FLAG)
If you use the F character instead of a register name debug displays the current status of the flags register. Each flag has a two letter code to shown the condition of the flags. To set or clear the flags use the following list of two letter codes.

FLAG NAME------------SET---------------CLEAR
Direction-------------------dn-------------------up (increment)
Interrupt--------------------ei (enabled)------di (disabled)
Sign--------------------------ng (neg)-----------pl (positive)
Auxiliary carry-------------ac-------------------na
Parity-------------------------pe (even)---------po (odd)

Default settings for debug

When you start debug, the segments registers are set to what ever segment is free in your computer at the lowest possible memory location, the IP register is set to 0100, all flags are cleared and the remaining registers are cleared to zero except the SP register, which is set to FFFE.


To put the number 1234 into the AX register, enter

RAX (return)

you will see

AX 0000:

after the colon enter 1234 (return)

To see just the flags register enter,

rf (return)

you will see


at the hyphen enter the two letter code for the flag,you want to affect.

pl ei cy (return)

  • Chapter 4
  • Return to Home Page.