DEBUG is an external command in DOS, and it has been included since DOS 1.0, so the importance of this command is evident. Although this command is very powerful and can solve many problems, it is very difficult for many people, especially beginners, to master. Therefore, the detailed introduction of the DEBUG commands is now presented to let everyone know how to use them.
Debug:A (Assemble)
Directly merge 8086/8087/8088 machine codes into memory.
This command creates executable machine code from assembly language statements. All values are in hexadecimal format, and these values must be entered as one to four characters. Prefix machine codes are specified before the referenced operation code (opcode).
a
Parameters
address
Specifies the location where assembly language instructions are typed. Use hexadecimal values for address and type each value without ending with the "h" character. If address is not specified, a will start assembling from where it last stopped.
For information about entering data into the specified byte, click "Related Topics" list for Debug E (Type).
For information about disassembling bytes, click "Related Topics" list for Debug U (Disassemble).
Description
Using machine codes
Alternative machine codes for segments are cs:, ds:, es:, and ss:. The machine code for a far return is retf. Machine codes for string processing must explicitly declare the string size. For example, using movsw moves a 16-bit string, and using movsb moves an 8-bit byte string.
Assembling jumps and calls
The assembler automatically assembles short, near, and far jumps and calls to target addresses based on byte substitution. Such jumps or calls can be replaced by using the near or far prefixes, as shown in the following example:
-a0100:0500
0100:0500 jmp 502 ; a 2-byte short jump
0100:0502 jmp near 505 ; a 3-byte near jump
0100:0505 jmp far 50a ; a 5-byte far jump
The near prefix can be abbreviated as ne.
Distinguishing word and byte memory locations
When an operand can reference a word memory location or a byte memory location, the data type must be specified using the prefix word ptr or prefix byte ptr. The acceptable abbreviations are wo and by respectively. The following example shows both formats:
dec wo
neg byte ptr
Specifying operands
Debug uses the idiom of referencing memory addresses with operands enclosed in brackets (). This is because Debug cannot distinguish between immediate operands and memory address operands on the other hand. The following example shows both formats:
mov ax,21 ; load AX with 21h
mov ax, ; load AX with the
; contents of
; memory location 21h
Using pseudoinstructions
The a command provides two common pseudoinstructions: the db opcode, which directly assembles byte values into memory, and the dw opcode, which directly assembles word values into memory. The following are examples of the two pseudoinstructions:
db 1,2,3,4,"THIS IS AN EXAMPLE"
db 'THIS IS A QUOTATION MARK:"'
db "THIS IS A QUOTATION MARK:'"
dw 1000,2000,3000,"BACH"
Example
The a command supports all forms of indirect register commands, as shown in the following example:
add bx,34.
pop
push )
All opcode synonyms are also supported, as shown in the following example:
loopz 100
loope 100
ja 200
jnbe 200
For 8087 opcodes, the wait or fwait prefix must be specified, as shown in the following example:
fwait fadd st,st(3) ; this line assembles
; an fwait prefix
Debug:C (Compare)
Compare two parts of memory.
c range address
Parameters
range
Specifies the start and end addresses of the first memory area to be compared, or the start address and length. For information about valid range values, click "Related Topics" list for "Debug Description".
address
Specifies the start address of the second memory area to be compared. For information about valid address values, click "Related Topics" list for "Debug Description".
Description
If the range and address memory areas are the same, Debug will not display anything and will directly return to the Debug prompt. If there are differences, Debug will display in the following format:
address1 byte1 byte2 addess2
Example
The following commands have the same effect:
c100,10f 300
c100l10 300
Each command compares the memory block from 100h to 10Fh with the memory block from 300h to 30Fh.
Computer Tutorial DEBUG Command Details from www.itwen.comIT WEN Computer Tutorial Network
Debug responds to the previous command and displays the following information (assuming DS = 197F):
197F:0100 4D E4 197F:0300
197F:0101 67 99 197F:0301
197F:0102 A3 27 197F:0302
197F:0103 35 F3 197F:0303
197F:0104 97 BD 197F:0304
197F:0105 04 35 197F:0305
197F:0107 76 71 197F:0307
197F:0108 E6 11 197F:0308
197F:0109 19 2C 197F:0309
197F:010A 80 0A 197F:030A
197F:010B 36 7F 197F:030B
197F:010C BE 22 197F:030C
197F:010D 83 93 197F:030D
197F:010E 49 77 197F:030E
197F:010F 4F 8A 197F:030F
Note that addresses 197F:0106 and 197F:0306 are missing from the list. This indicates that the values in those addresses are the same.
Debug:D (Dump)
Display the contents of a range of memory addresses.
d
Parameters
range
Specifies the start and end addresses of the memory area whose contents are to be displayed, or the start address and length. For information about valid range values, click "Related Topics" list for "Debug Description". If range is not specified, the Debug program will display the contents of 128 bytes starting from the end of the address range specified in the previous d command.
For information about displaying register contents, click "Related Topics" list for Debug R (Registers).
Description
When using the d command, Debug displays the memory contents in two parts: the hexadecimal part (each byte's value is expressed in hexadecimal format) and the ASCII part (each byte's value is expressed in ASCII characters). Each non-printable character is represented by a period (.) in the displayed ASCII part. Each display line shows 16 bytes of content, with a hyphen between the 8th and 9th bytes. Each display line starts on a 16-byte boundary.
Example
Assume the following command is typed:
dcs:100 10f
Debug displays the contents of the range in the following format:
04BA:0100 54 4F 4D 00 53 41 57 59-45 52 00 00 00 00 00 00 TOM.SAWYER......
If the d command is typed without parameters, Debug arranges the display format as described in the previous example. Each displayed line starts with an address that is 16 bytes larger than the address of the previous line (8 bytes if the screen is 40 columns).
For each subsequent d command typed without parameters, Debug will immediately display the byte contents immediately after the last displayed command.
If the following command is typed, Debug will display the contents of 20h bytes starting from CS:100:
dcs:100 l 20
If the following command is typed, Debug will display the contents of all bytes in the range from 100h to 115h in the CS segment:
dcs:100 115
Debug:E (Enter)
Enter data into the specified address in memory.
Data can be entered in hexadecimal or ASCII format. Any data previously stored in the specified location is completely lost.
e address
Parameters
address
Specifies the first memory location where data is entered.
list
Specifies the data to be entered into consecutive bytes in memory.
For information about integrated machine codes, click "Related Topics" list for Debug A (Assemble).
For information about displaying part of the memory contents, click "Related Topics" list for Debug D (Dump).
Description
Using the address parameter
If the value of address is specified without specifying the value of the optional list parameter, Debug will display the address and contents, repeat the address on the next line, and wait for your input. At this time, you can do one of the following:
Replace the byte value. To do this, type the new value after the current value. If the value you type is not a valid hexadecimal value or contains more than two digits, Debug will not echo invalid or extra characters.
Advance to the next byte. To do this, press the SPACEBAR. To change the value in this byte, type the new value after the current value. If pressing the SPACEBAR moves beyond the 8-bit boundary, the Debug program will display a new line and display the new address at the beginning of the line.
Go back to the previous byte. To do this, press the HYPHEN key (-). You can repeatedly press the HYPHEN key (-) to move back more than one byte. When pressing HYPHEN, Debug starts a new line and displays the current address and byte value.
Stop executing the e command. To do this, press the ENTER key. You can press ENTER at any byte position.
Using the list parameter
If the value of the list parameter is specified, the subsequent e command will replace the existing byte values with the values in the list. If an error occurs, no byte values will be changed.
List values can be hexadecimal bytes or strings. Use spaces, commas, or tabs to separate values. Strings must be enclosed in single or double quotes.
Example
Assume the following command is typed:
ecs:100
Debug displays the contents of the first byte in the following format:
04BA:0100 EB.
To change this value to 41, type 41 at the insertion point, as follows:
04BA:0100 EB.41_
You can enter consecutive byte values with one e command. Press the SPACEBAR after typing a new value instead of pressing the ENTER key. Debug displays the next value. In this example, if you press the SPACEBAR three times, Debug will display the following values:
04BA:0100 EB.41 10. 00. BC._
To change the hexadecimal value BC to 42, type 42 at the insertion point, as follows:
04BA:0100 EB.41 10. 00. BC.42_
Assume that you decide that the value 10 should be 6F. To correct this value, press the HYPHEN key twice to go back to address 0101 (value 10). Debug displays the following:
04BA:0100 EB.41 10. 00. BC.42-
04BA:0102 00.-
04BA:0101 10._
Type 6f at the insertion point to change the value, as follows:
04BA:0101 10.6f_
Press ENTER to stop the e command and return to the Debug prompt.
The following is an example of a string item:
eds:100 "This is the text example"
This string will fill 24 bytes starting from DS:100
Debug:F (Fill)
Fill the addresses in the specified memory area with the specified value.
Data can be specified in hexadecimal or ASCII format. Any data previously stored in the specified location will be lost.
f range list
Parameters
range
Specifies the start and end addresses of the memory area to be filled, or the start address and length. For information about valid range values, click "Related Topics" list for "Debug Description".
list
Specifies the data to be entered. List can consist of hexadecimal numbers or strings enclosed in quotes.
Description
Using the range parameter
If the number of bytes in range is larger than the number of values in list, Debug will repeatedly assign values from list until all bytes in range are filled.
If any memory in range is damaged or does not exist, Debug will display an error message and stop the f command.
Using the list parameter
If the number of values in list is more than the number of bytes in range, Debug will ignore the extra values in list.
Example
Assume the following command is typed:
f04ba:100l100 42 45 52 54 41
In response, Debug fills the memory locations from 04BA:100 to 04BA:1FF with the specified values. Debug repeats these five values until 100h bytes are completely filled.
Debug:G (Go)
Run the program currently in memory.
g
Parameters
=address
Specifies the address of the program in memory where execution is to start. If address is not specified, Windows 2000 will start executing the program from the current address in the CS:IP register.
breakpoints
Specifies 1 to 10 temporary breakpoints that can be set as part of the g command.
For information about executing loops, repeated string instructions, software interrupts, or subroutines, click "Related Topics" list for Debug P (Execute).
For information about executing instructions, click "Related Topics" list for Debug T (Trace).
Debug:H (Hexadecimal)
Perform hexadecimal operations on the specified two parameters.
h value1 value2
Parameters
value1
Represents any hexadecimal digit in the range from 0 to FFFFh.
value2
Represents the second hexadecimal digit in the range from 0 to FFFFh.
Description
Debug first adds the specified two parameters, then subtracts the second parameter from the first parameter. The results of these calculations are displayed in one line: first the sum, then the difference.
Example
Assume the following command is typed:
h19f 10a
Debug performs the operation and displays the following result.
02A9 0095
Debug:I (Input)
Read and display a byte value from the specified port.
i port
Parameters
port
Specifies the input port by address. The address can be a 16-bit value.
For information about sending byte values to the output port, click "Related Topics" list for Debug O (Output).
Example
Assume the following command is typed:
i2f8
Also assume that the byte value of the port is 42h. Debug reads this byte and displays its value as follows:
42
Debug:L (Load)
Load the contents of a file or specific disk sector into memory.
To load the contents of the number of bytes specified in the BX:CX registers from a disk file, use the following syntax:
l
To skip the Windows 2000 file system and directly load a specific sector, use the following syntax:
l address drive start number
Parameters
address
Specifies the memory location where the contents of the file or sector are to be loaded. If address is not specified, Debug will use the current address in the CS register.
drive
Specifies the drive containing the disk from which the specified sector is read. This value is numeric: 0 = A, 1 = B, 2 = C, etc.
start
Specifies the hexadecimal number of the first sector whose contents are to be loaded.
number
Specifies the hexadecimal number of the consecutive sectors whose contents are to be loaded. The drive, start, and number parameters can only be used if you want to load the contents of a specific sector instead of the file specified in the debug command line or the most recent Debug n (Name) command.
For information about specifying the file for the l command, click "Related Topics" list for Debug n (Name).
For information about writing files debugged to disk, click "Related Topics" list for Debug W (Write).
Note
Using the l command without parameters
When using the l command without parameters, the file specified on the debug command line will be loaded into memory starting from address CS:100. Debug also sets the BX and CX registers to the number of bytes loaded. If no file is specified on the debug command line, the loaded file will be the one most frequently specified using the n command.
Using the 1 command with the address parameter
If you use the l command with the address parameter, Debug will load the contents of the file or specified sector starting from memory location address.
Using the l command with all parameters
If you use the l command with all parameters, Debug will load the contents of the specified disk sector instead of the file.
Loading the contents of a specific sector
Each sector in the specified range is read from drive. Debug loads from start until the contents of the number of sectors specified in number are all loaded.
Loading an .exe file
Debug ignores the address parameter of the .exe file. If an .exe file is specified, Debug will reposition the file to the load address specified in the header of the .exe file. Before the .exe file is loaded into memory, the header itself is detached from the .exe file, so the size of the .exe file on disk is different from that in memory. If you want to check the entire .exe file, rename the file with a different extension.
Opening a hexadecimal file
Debug considers a file with the .hex extension as a hexadecimal format file. Typing the l command without parameters can load the hexadecimal file starting from the address specified in the hexadecimal file. If the typed l command contains the address parameter, Debug will add the specified address to the address found in the hexadecimal file to determine the starting address.
Example
Assume that Debug is started and the following command is typed:
nfile.com
Now you can type the l command to load File.com. Debug will load the file and display the Debug prompt.
Assume that you need to load the contents of 109 (6Dh) sectors starting from logical sector 15 (0Fh) from drive C into memory starting at address 04BA:0100. To do this, type the following command:
l04ba:100 2 0f 6d
Debug:M (Move)
Copy the contents of one memory block to another memory block.
m range address
Parameters
range
Specifies the start and end addresses of the memory area whose contents are to be copied, or the start address and length.
address
Specifies the start address to which the range contents are to be copied.
Description
Impact of copy operations on existing data
If the new data is not written to the address in the data block being copied, the source data will remain unchanged. However, if the target block already contains data (as in an overwrite copy operation), that data will be overwritten. (An overwrite copy operation is one where part of the target data block overwrites part of the source data block.)
Performing an overwrite copy operation
The m command performs an overwrite copy operation of the target address without losing data. The contents of the address being overwritten are copied first. Therefore, if data from a higher address is copied to a lower address, the copy operation starts from the lowest address of the source block and proceeds to the highest address. Conversely, if data is copied from a lower address to a higher address, the copy operation starts from the highest address of the source block and proceeds to the lowest address.
Example
Assume the following command is typed:
mcs:100 110 cs:500
Debug first copies the contents at address CS:110 to address CS:510, then copies the contents at address CS:10F to CS:50F, and so on until the contents at address CS:100 are copied to address CS:500. To view the result, use the Debug d (Dump) command and specify the target address using the m command
Debug:N (Name)
Specify the name of the executable file for the Debug l (Load) or w (Write) command, or specify the parameters of the executable file being debugged.
n filename
To specify the parameters of the executable file to be tested, use the following syntax:
n file-parameters
Parameters
If used without parameters, the n command clears the current specification.
filename
Specifies the location and name of the executable file to be tested.
file-parameters
Specifies parameters and switches for the executable file being tested.
For information about loading the contents of a file or specified disk sector into memory, click "Related Topics" list for Debug L (Load).
For information about writing files debugged to disk, click "Related Topics" list for Debug W (Write).
Description
Two uses of the n command
The n command can be used in two ways. First, you can use it to specify the file to be used by the subsequent l (Load) or w (Write) command. If Debug is started without naming the file being debugged, you must use the command nfilename before using the l command to load the file. The filename is properly formatted in the file control block (FCB) at CS:5C. Second, you can use the n command to specify the command-line parameters and switches of the file being debugged.
Memory areas
The following four memory areas are affected by the n command:
Memory location
Content
CS:5C
File control data block (FCB) for file 1
CS:6C
File control data block (FCB) for file 2
CS:80
Length of the n command line (in characters)
CS:81
Start of the characters in the n command line
The first filename specified for the n command is placed in the FCB at CS:5C. If a second filename is specified, this name will be placed in the FCB at CS:6C. The number of characters typed on the n command line (excluding the first character, n) is stored in location CS:80. The actual characters on the n command line (again, excluding the letter n) are stored in the location starting at CS:81. Note that these characters can be any switches and separators valid in the command typed at the Windows 2000 command prompt.
Example
Assume that Debug has been started and the program Prog.com being debugged has been loaded. Then you decide to specify two parameters for Prog.com and run this program. The following is the command sequence for this example:
debug prog.com
nparam1 param2
g
In this case, the Debug g (Go) command will run the program as if you had typed the following command after the Windows 2000 command prompt:
prog param1 param2
So, the test and debugging reflect the usual runtime environment of Prog.com.
In the following command sequence, the first n command specifies File1.exe as the file for the subsequent l (Load) command, which will load File1.exe into memory. The second n command specifies the parameters that File1.exe will use. Finally, the g command will run the File1.exe file as if you had typed File1 File2.dat File2.dat on the Windows 2000 command line.
nfile1.exe
l
nfile2.dat file3.dat
g
Note
Do not use the l command after the second form of the n command. Also note that if you now use the w (Write) command, Windows 2000 will save the file being debugged File1.exe with the name File2.dat. To avoid this result, you should always use the first form of the n command immediately before the l or w command.
Debug:O (Output)
Send a byte value to the output port.
o port byte-value
Parameters
port
Specifies the output port by address. The port address can be a 16-bit value.
byte-value
Specifies the byte value to be directed to port.
For information about reading a byte value from the input port, click "Related Topics" list for Debug I (Input).
Example
To send the byte value 4Fh to the output port with address 2F8h, type the following command:
o2f8 4f
Debug:P (Execute)
Execute loops, repeated string instructions, software interrupts, or subroutines; or trace through any other instructions.
p
Parameters
=address
Specifies the location of the first instruction to be executed. If no address is specified, the default address is the current address specified in the CS:IP register.
number
Specifies the number of instructions to be executed before control is returned to Debug. The default value is 1.
For information about running the program currently in memory, click "Related Topics" list for Debug G (Go).
For information about executing instructions, click "Related Topics" list for Debug T (Trace).
Description
Control is transferred to the program being tested
When the p command transfers control from Debug to the program being tested, the program runs uninterrupted until the loop, repeated string instruction, software interrupt, or subroutine at the specified address is completed, or until the specified number of machine instructions are executed. Control returns to Debug.
Limitations of the address parameter
If the address parameter does not specify a segment, Debug will use the CS register of the program being tested. If address is omitted, the program will start executing from the address specified in the CS:IP register. The equal sign (=) must be used before the address parameter to distinguish it from the number parameter. If the instruction at the specified address is not a loop, repeated string instruction, software interrupt, or subroutine, the p command has the same effect as the Debug t (Trace) command.
Mail displayed using the p command
When p finishes executing a segment, Debug displays the register contents of the program, the state of the flags, and the decoded form of the next instruction to be executed.
Warning
The p command cannot be used to trace read-only memory (ROM).
Example
Assume that the program being tested contains a call instruction at address CS:143F. To run the subroutine at the target location of the call and then return control to Debug, type the following command:
p=143f
Debug displays the result in the following format:
AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=2246 ES=2246 SS=2246 CS=2246 IP=1443 NV UP EI PL NZ AC PO NC
2246:1442 7505 JNZ 144A
Debug:Q (Quit)
Stop the Debug session without saving the currently tested file.
When you type q, control returns to the Windows 2000 command prompt.
q
Parameters
This command has no parameters.
For information about saving files, click "Related Topics" list for Debug W (Write).
Debug:R (Registers)
Display or change the contents of one or more CPU registers.
r
Parameters
None
If used without parameters, the r command displays the contents of all registers and the flags in the register storage area.
register-name
Specifies the name of the register whose contents are to be displayed.
For information about displaying part of the memory contents, click "Related Topics" list for Debug D (Dump).
For information about disassembling bytes, click "Related Topics" list for Debug U (Disassemble).
Description
Using the r command
If a register name is specified, Windows 2000 will display the 16-bit value of the register in hexadecimal notation and display a colon as a prompt. If you want to change the value contained in the register, press ENTER to return to the Debug prompt unless you type a new value and press ENTER.
Valid register names
The following are valid values for register-name: ax, bx, cx, dx, sp, bp, si, di, ds, es, ss, cs, ip, pc, and f. Both ip and pc refer to the instruction pointer.
If a register name is specified that is not from the previous list, Windows 2000 will display the following message:
br error
Using the f character instead of a register name
If you type the f character instead of the register name, Debug will display the current setting of each flag as a two-letter code, then display the Debug prompt. To change the flag settings, type the appropriate two-letter code from the following table:
Flag name
Set
Clear
Overflow
ov
nv
Direction
dn (decrement)
up (increment)
Interrupt
ei (enable)
di (disable)
Sign
ng (negative)
pl (positive)
Zero
zr
nz
Auxiliary carry
ac
na
Parity
pe (even parity)
po (odd parity)
Carry
cy
nc
You can type the new flag values in any order. No spaces are needed between these values. To stop the r command, press ENTER. Any flags for which no new value is specified remain unchanged.
Mail displayed with the r command
If multiple values are specified for a flag, Debug will display the following message:
df error
If a flag code not listed in the previous table is specified, Debug will display the following message:
bf error
In both cases, Debug will ignore all settings specified after the invalid item.
Default settings of Debug
When Debug is started, the segment registers are set to the low end of free memory, the instruction pointer is set to 0100h, all flags are cleared, and the remaining registers are set to zero, except for sp, which is set to FFEEh.
Debug:R
Example
To view the contents of all registers, the state of all flags, and the instruction decoding table at the current location, type the following command:
r
If the current location is CS:11A, the display will look similar to the following:
AX=0E00 BX=00FF CX=0007 DX=01FF SP=039D BP=0000 SI=005C DI=0000
DS=04BA ES=04BA SS=04BA CS=O4BA IP=011A NV UP DI NG NZ AC PE NC
04BA:011A CD21 INT 21
To view only the state of the flags, type the following command:
rf
Debug displays the information in the following format:
NV UP DI NG NZ AC PE NC - _
Now, you can type one or more valid flag values in any order, with or without spaces, as follows:
nv up di ng nz ac pe nc - pleicy
Debug ends the r command and displays the Debug prompt. To view the changes, type the r or rf command. Debug will display the following:
NV UP EI PL NZ AC PE CY - _
Press ENTER to return to the Debug prompt.
Debug:S (Search)
Search a range of addresses for a pattern of one or more byte values.
s range list
Parameters
range
Specifies the start and end addresses of the range to be searched. For information about valid values of the range parameter, click "Related Topics" list for Debug.
list
Specifies a pattern of one or more byte values, or a string to be searched. Separate each byte value from the next with a space or comma. Enclose string values in quotes.
Description
If the list parameter contains multiple byte values, Debug will only display the first address where the byte values occur. If the list contains only one byte value, Debug will display all addresses where that value occurs in the specified range.
Example
Assume that you need to find all addresses containing the value 41 and in the range from CS:100 to CS:110. To do this, type the following command:
scs:100 110 41
Debug displays the result in the following format:
04BA:0104
04BA:010D
-
The following command searches for the string "Ph" in the range from CS:100 to CS:1A0.
scs:100 1a0 "Ph"
Debug:U (Disassemble)
Disassemble bytes and display the corresponding original statement, including the address and byte value. The disassembled code looks like a list of assembled files.
u
Parameters
None
If used without parameters, the u command disassembles 20h bytes (default) starting from the first address after the address displayed by the previous u command.
range
Specifies the start and end addresses, or start address and length, of the code to be disassembled. For information about valid values of the range parameter, click "Related Topics" list for Debug.
For information about integrated machine codes, click "Related Topics" list for Debug A (Assemble).
For information about displaying part of the memory contents, click "Related Topics" list for Debug D (Dump).
Example
To disassemble 16 (10h) bytes starting from address 04BA:0100, type the following command:
u04ba:100l10
Debug displays the result in the following format:
04BA:0100 206472 AND ,AH
04BA:0103 69 DB 69
04BA:0104 7665 JBE 016B
04BA:0106 207370 AND ,DH
04BA:0109 65 DB 65
04BA:010A 63 DB 63
04BA:010B 69 DB 69
04BA:010C 66 DB 66
04BA:010D 69 DB 69
04BA:010E 63 DB 63
04BA:010F 61 DB 61
If you only want to display information for specific addresses from 04BA:0100 to 04BA:0108, type the following command:
u04ba:0100 0108
Debug displays the following:
04BA:0100 206472 AND ,AH
04BA:0103 69 DB 69
04BA:0104 7665 JBE 016B
04BA:0106 207370 AND ,DH
Debug:W (Write)
Write a file or specific partition to disk.
To write the contents of the number of bytes specified in the BX:CX registers to a disk file, use the following syntax:
w
To skip the Windows 2000 file system and directly write to a specific sector, use the following syntax:
w address drive start number
Parameters
address
Specifies the starting memory address of the file or part of the file to be written to the disk file. If address is not specified, the Debug program will start from CS:100. For information about valid values of the address parameter, click Debug in the "Related Topics" list.
drive
Specifies the drive containing the target disk. This value is numeric: 0 = A, 1 = B, 2 = C, etc.
start
Specifies the hexadecimal number of the first sector to be written.
number
Specifies the number of sectors to be written.
For information about specifying the file for the w command, click "Related Topics" list for Debug N (Name).
For information about loading the contents of a file or file sector into memory, click "Related Topics" list for Debug L (Load).
Description
The name of the disk file must be specified either when Debug is started or in the most recent Debug n (Name) command. Both methods correctly format the filename in the file control block at address CS:5C.
Reset BX:CX before using the w command without parameters
If the Debug g (Go), t (Trace), p (Execute), or r (Registers) command has been used, the BX:CX registers must be reset before using the w command without parameters.
Writing a modified file to disk
If the file is modified but the filename, length, or start address is not changed, Debug can still correctly write the file to the source disk location.
Limitations of the w command
This command cannot be used to write .exe or .hex files.
Warning
Writing to a specific partition is very dangerous because the Windows 2000 file handle is skipped. If incorrect values are typed, the disk file structure can be easily damaged.
Example
Assume that you want to write the memory contents starting from address CS:100 to the disk in drive B. You need to start data from logical sector number 37h on the disk and continue for 2Bh sectors. To do this, type the following command:
wcs:100 1 37 2b
When the write operation is completed, Debug again displays the Debug prompt.
Debug:XA (Allocate Extended Memory)
Allocate the specified number of pages of extended memory.
To use extended memory, an extended memory device driver compliant with the Lotus/Intel/Microsoft Extended Memory Specification (LIM EMS) version 4.0 must be installed.
xa
Parameters
count
Specifies the number of 16KB pages of extended memory to be allocated.
For information about other Debug commands for using extended memory, click "Related Topics" list for XD (Free Extended Memory), XM (Map Extended Memory Page), or XS (Display Extended Memory Status).
Description
If the specified number of pages is available, Debug will display a message indicating the hexadecimal number of the created handle; otherwise, Debug will display an error message.
Debug:XA
Example
To allocate 8 pages of extended memory, type the following command:
xa8
If the command is successful, Debug will display a message similar to the following:
Handle created=0003
Debug:XD (Free Extended Memory)
Free the handle pointing to extended memory.
To use extended memory, an extended memory device driver compliant with the Lotus/Intel/Microsoft Extended Memory Specification (LIM EMS) version 4.0 must be installed.
xd
Parameters
handle
Specifies the handle to be freed.
For information about other Debug commands for using extended memory, click "Related Topics" list for XA (Allocate Extended Memory), XM (Map Extended Memory Page), or XS (Display Extended Memory Status).
Example
To free handle 0003, type the following command:
xd 0003
If the command is successful, Debug will display the following message:
Hdle 0003 deallocated
Debug:XM (Map Extended Memory Page)
Map the extended memory logical page belonging to the specified handle to the physical page of extended memory.
To use extended memory, an extended memory device driver compliant with the Lotus/Intel/Microsoft Extended Memory Specification (LIM EMS) version 4.0 must be installed.
xm
Parameters
lpage
Specifies the logical page number of extended memory to be mapped to physical page ppage.
ppage
Specifies the physical page number to which lpage is mapped.
handle
Specifies the handle.
For information about other Debug commands for using extended memory, click "Related Topics" list for XA (Allocate Extended Memory), XD (Free Extended Memory), or XS (Display Extended Memory).
Example
To map logical page 5 of handle 0003 to physical page 2, type the following command:
xm 5 2 0003
If the command is successful, Debug will display the following message:
Logical page 05 mapped to physical page 02
Debug:XS (Display Extended Memory Status)
Display information about the status of extended memory.
To use extended memory, an extended memory device driver compliant with the Lotus/Intel/Microsoft Extended Memory Specification (LIM EMS) version 4.0 must be installed.
xs
Parameters
This command has no parameters.
For information about other Debug commands for using extended memory, click "Related Topics" list for XA (Allocate Extended Memory), XD (Free Extended Memory), or XM (Map Extended Memory Page).
Description
The information displayed by Debug has the following format:
Handle xx has xx pages allocated
Physical page xx = Frame segment xx
xx of a total xx EMS pages have been allocated
xx of a total xx EMS handles have been allocated
Example
To display extended memory information, type the following command:
xs
Debug displays information similar to the following:
Handle 0000 has 0000 pages allocated
Handle 0001 has 0002 pages allocated
Physical page 00 = Frame segment C000
Physical page 01 = Frame segment C400
Physical page 02 = Frame segment C800
Physical page 03 = Frame segment CC00
2 of a total 80 EMS pages have been allocated
2 of a total FF EMS handles have been allocated