Start DEBUG
1. Open the Windows command window
In the Windows 95/98 environment, the steps to open the command window are: click "Start" → "Run", and enter the "command" command; In the Windows XP and WIN7 environment, the steps to open the command window are: click "Start" → "Run", and enter the "cmd" command;
2. Start DEBUG
Start DEBUG in the command window. The startup command is generally: DEBUG [File name] [Parameter table]. Where: the file name specifies the file to be debugged, which includes the name and suffix, and the parameter table is the parameters required for the debugged file to run. The file being debugged can be any file in the system, but usually their suffix is .EXE or .COM. When the DEBUG is successfully started, the connector "-" will be displayed. At this time, various DEBUG commands can be entered. All commands and their meanings in DEBUG are shown in the function description table of each command in DEBUG. A few instructions on using commands: You can only enter the command at the prompt "-". After pressing the "Enter" key, the command will start executing the command. The command is a single letter. The command and the case of the command and the parameters can be input mixed. You can edit the command in this line. When the command has a syntax error, the "^ Error" will be displayed at the error position. You can also use Ctrl+C or Ctrl+Break to terminate the execution of the current command. You can also use Ctrl+S or Ctrl+Num Lock to pause the screen display (when the information is continuously displayed)
The following is to familiarize yourself with the command set and basic assembly instructions of DEBUG through implementation nineteen examples.
Debug:A (assembly)
Directly merge the 8086/8087/8088 memory code into memory.
This command creates executable machine code from assembly language statements. All values are in hexadecimal format and must be entered in one to four characters. Specify the prefix memory code before the referenced operation code (opcode).
a [address]
parameter
address
Specifies the location where to type the assembly language directive. Use hexadecimal values for address and type each value that does not end with the "h" character. If the address is not specified, a will start assembly at its last stop.
For information on entering data into the specified bytes, see Debug E (Typing).
For information on disassembly bytes, see Debug U (disassembly)
illustrate
Use memory code
The alternative memory codes for segments are cs:, ds:, es: and ss:. The memory code returned remotely is retf. The memory code for string processing must clearly declare the string size. For example, using movsw can move a 16-bit string, and using movsb can move an 8-bit byte string.
Assembly jumps and calls
The assembler automatically assembles short, near and far jumps and calls to the target address based on byte replacement. Such jumps or calls can be replaced by using the near or far prefix, 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.
Distinguish between word and byte memory locations
When an operand can refer to a word memory location or byte memory location, the data type must be specified with the prefix word ptr or the prefix byte ptr. Acceptable abbreviations are wo and by. The following examples show two formats:
dec wo [si]
neg byte ptr [128]
Specify operands
Debug Idiom for referring to memory addresses using operands included in brackets ([ ]). This is because, on the other hand, Debug cannot distinguish between immediate operands and memory addresses operands. The following examples show two formats:
mov ax,21 ; load AX with 21h
mov ax,[21] ; load AX with the
; contents of
; memory location 21h
Use pseudo-directives
Use the a command to provide two commonly used pseudo-instructions: db opcode, which directly assembles byte values into memory, and dw opcode, which directly assembles word values into memory. Here are two examples of pseudo-instructions:
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 registration commands, as shown in the following example:
add bx,34[bp+2].[si-1]
pop [bp+di]
push [si] )
All opcode synonyms are also supported, as shown in the following example:
loopz 100
loope 100
ja 200
jnbe 200
For the 8087 opcode, 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
parameter
range
Specifies the start and end addresses, or start addresses and lengths of the first area of memory to be compared.
address
Specifies the start address of the second memory area to be compared. For information about valid address values, see "Debug Description".
illustrate
If the range and address memory areas are the same, Debug will not display anything and will return directly to the Debug prompt. If there is a difference, Debug will be displayed in the following format:
address1 byte1 byte2 addess2
example
The following command has the same effect:
c100,10f 300
c100l10 300
Each command compares memory blocks from 100h to 10Fh with memory blocks from 300h to 30Fh.
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 the address 197F:0106 and 197F:0306 are missing in the list. This indicates that the values in those addresses are the same.
Debug:D (Dump)
Displays the contents of a certain range of memory addresses.
d [range]
parameter
range
Specifies the start and end addresses, or start addresses and lengths of the memory area whose contents you want to display. If range is not specified, the Debug program will display 128 bytes of content starting from the end of the address range specified in the previous d command.
For information on displaying register contents, see Debug R (Register).
illustrate
When using the d command, Debug displays memory contents in two parts: the hexadecimal part (the value of each byte is represented in hexadecimal format) and the ASCII code part (the value of each byte is represented in ASCII code characters). Each non-printed character is represented by a period (.) in the ASCII portion of the display. Each display line displays 16 bytes of contents, with a hyphen between bytes 8 and 9. Each display line starts at a 16-byte boundary.
example
Assume that you type the following command:
dcs:100 10f
Debug Displays content in the range in the following format:
04BA:0100 54 4F 4D 00 53 41 57 59-45 52 00 00 00 00 00 00 ......
If you type the d command without parameters, Debug arranges the display format as described in the previous examples. Each row displayed begins with an address that is 16 bytes larger than the address of the previous row (8 bytes if it is a screen showing 40 columns).
For each d command without parameters typed later, Debug displays the byte content immediately after the last displayed command.
If you type the following command, Debug will display 20h bytes starting from CS:100:
dcs:100 l 20
If you type the following command, Debug displays the contents of all bytes ranging from 100h to 115h of the CS segment:
dcs:100 115
Debug:E (Type)
Enter data to the specified address in memory.
Data can be typed in hexadecimal or ASCII format. Any data previously stored in the specified location is lost.
e address [list]
parameter
address
Specifies the first memory location for input data.
list
Specifies the data to be entered into consecutive bytes of memory.
For information on integrated memory codes, see Debug A (assembly).
For information on displaying parts of memory, see Debug D (Dump).
illustrate
Use the address parameter
If you specify the value of address without specifying the optional list parameter, Debug will display the address and content, repeat the address on the next line, and wait for your input. At this point, you can do one of the following:
Replace byte value. To do this, type a new value after the current value. If the value you type is not a valid hexadecimal value, or the value contains more than two numbers, Debug does not echo invalid or additional characters.
Go to the next byte. To do this, press SPACEBAR. To change the value in that byte, type a new value after the current value. If the 8-bit boundary move exceeds the 8-bit limit when SPACEBAR is pressed, the Debug program will display a new row and display a new address at the beginning of the row.
Return to the previous byte. To do this, press the HYPHEN key (-). You can repeatedly press the HYPHEN key (-) to move backwards for more than multiple bytes. When HYPHEN is pressed, Debug starts a new line and displays the current address and byte values.
Stop executing the e command. To do this, press the ENTER key. ENTER can be pressed at any byte position.
Use list parameters
If the value of the list parameter is specified, the subsequent e command replaces the existing byte value with the value in the list. If an error occurs, no byte value will be changed.
The List value can be a hexadecimal byte or a string. Use spaces, commas, or tabs to separate values. The string must be included in single or double quotes.
example
Assume that you type the following command:
ecs:100
Debug displays the contents of the first byte in the following format:
04BA:0100 EB.
To change the value to 41, type 41 at the insertion point, as follows:
04BA:0100 EB.41_
You can type consecutive byte values with an e command. Press SPACEBAR (Spacebar) after typing a new value instead of ENTER. Debug Displays the next value. In this example, if SPACEBAR is pressed 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 the decision value 10 should be 6F. To correct this value, press the HYPHEN twice to return 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.
Here is an example of a string item:
eds:100 "This is the text example"
The string will be filled with 24 bytes starting from DS:100
Debug:F (Fill)
Fill the address in the specified memory area with the specified value.
You can specify data in hexadecimal or ASCII format. Any data previously stored in the specified location will be lost.
f range list
parameter
range
Specifies the start and end addresses, or start addresses and lengths of the memory area to be filled. For information about valid range values, see "Debug Description".
list
Specifies the data to enter. List can be composed of a string of hexadecimal numbers or quotes.
illustrate
Use range parameters
If the range contains a larger number of bytes than the value in the list, Debug will repeatedly assign the value in the list until all bytes in the range are filled.
If any memory in the range is corrupted or does not exist, Debug displays an error message and stops the f command.
Use list parameters
If list contains more values than the number of bytes in range, Debug ignores the extra values in list.
example
Assume that you type the following command:
f04ba:100l100 42 45 52 54 41
In response, Debug fills the memory location from 04BA:100 to 04BA:1FF with the specified value. Debug Repeat these five values until all 100h bytes are filled.
Debug:G (steering)
Run the program currently in memory.
g [=address] [breakpoints]
parameter
=address
Specifies the address of the program to be executed in memory. If address is not specified, Windows 2000 starts executing the program from the current address in the CS:IP register.
breakpoints
Specifies 1 to 10 temporary breakpoints that can be set to the part of the g command.
For information on executing loops, duplicate string instructions, software interrupts, or subroutines, see Debug P (Execution).
For information on executing instructions, see Debug T (tracking)
Debug:H (hexadecimal)
Performs hexadecimal operations on the specified two parameters.
h value1 value2
parameter
value1
Represents any hexadecimal number in the range from 0 to FFFFh.
value2
Represents the second hexadecimal number in the range from 0 to FFFFh.
illustrate
Debug First adds the specified two parameters and subtracts the second parameter from the first parameter. The results of these calculations are shown in a row: first calculate the sum and then calculate the difference.
example
Assume that you type the following command:
h19f 10a
Debug performs an operation and displays the following results.
02A9 0095
Debug:I (input)
Read and display a byte value from the specified port.
i port
parameter
port
Specify the input port by address. The address can be a 16-bit value.
For information on sending byte values to the output port, see Debug O (Output).
example
Assume that you type the following command:
i2f8
At the same time, it is assumed that the byte value of the port is 42h. Debug reads the byte and displays its value as follows:
42
Debug:L (Loading)
Load the contents of a file or a specific disk sector into memory.
To load the contents of the bytes specified in the BX:CX register from a disk file, use the following syntax:
l [address]
To skip the Windows 2000 file system and load a specific sector directly, use the following syntax:
l address drive start number
parameter
address
Specifies the memory location in which the file or sector contents are to be loaded. If address is not specified, Debug uses the current address in the CS register.
drive
Specifies the drive that contains the disk that reads the specified sector. This value is numerical: 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 the contents of a specific sector are loaded instead of the file specified in the debug command line or the most recent Debug n (name) command.
For information about specifying the file used for the l command, see Debug n (name).
For information about writing to files debugged to disk, see Debug w (Write).
Notice
Use the l command without parameters
When using the l command without parameters, the file specified on the debug command line is loaded into memory starting from address CS:100. Debug sets the BX and CX registers to the number of bytes loaded at the same time. If the file is not specified on the debug command line, the loaded file will be a file that is recently frequently specified using the n command.
Use 1 command with address parameter
If you use the l command with the address parameter, Debug will start loading the file or the contents of the specified sector from the memory location address.
Use the l command with all parameters
If the l command with all parameters is used, Debug will load the contents of the specified disk sector instead of the file.
Load the contents of a specific sector
Each sector in the specified range is read from drive. Debug loads from start until all contents of the number of sectors specified in number are loaded.
Loading .exe files
Debug ignores the address parameter of the .exe file. If you specify a .exe file, Debug relocates the file to the load address specified in the title of the .exe file. Before the .exe file is loaded into memory, the title itself is disconnected from the .exe file, so the .exe file size on disk is different from that in memory. If you want to check the entire .exe file, rename the file with a different extension.
Open a hexadecimal file
Debug considers files with .hex extensions hex format files. Type the l command without parameters to load the hex file starting from the address specified in the hex file. If the l command typed contains the address parameter, Debug adds the specified address to the address found in the hexadecimal file to determine the starting address.
example
Assume that Debug is started and type the following command:
You can now type the l command to load . Debug will load the file and display a Debug prompt.
Assume that the contents of 109 (6Dh) sectors with the starting logical sector of 15 (0Fh) need to be loaded into memory with the starting address of 04BA:0100 from drive C. To do this, type the following command:
l04ba:100 2 0f 6d
Debug:M (mobile)
Copy the contents of one memory block into another memory block.
m range address
parameter
range
Specifies the start and end addresses, or start addresses and lengths of the memory area to which the content is to be copied.
address
Specifies the starting address to which range contents are to be copied.
illustrate
The 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 the same. However, if the target block already contains data (as it does in the overwrite replica operation), the data will be overwritten. (The overwrite copy operation refers to the operation in which part of the target data block is covered by part of the original data block.)
Perform overwrite copy operation
The m command performs override copying operations of the target address without losing data. Copy the rewritten address content first. Therefore, if the data of the higher bit address is copied to the lower bit address, the copy operation starts from the lowest bit address of the original block and proceeds to the highest bit address. On the contrary, if you want to copy the data from the low address to the high address, the copy operation starts from the highest address of the original block and proceeds to the lowest address.
example
Assume that you type the following command:
mcs:100 110 cs:500
Debug First copy the contents of the CS:110 address to the address CS:510, and then copy the contents of the CS:10F address to the CS:50F, and then copy the contents of the CS:100 address to the address CS:500. To view the results, use the Debug d (dump) command and specify the destination address using the m command
Debug:N (name)
Specifies the name of the executable file for the Debug l (load) or w (write) command, or specifies the parameters of the executable file being debugged.
n [drive:][path] filename
To specify parameters for the test executable, use the following syntax:
n file-parameters
parameter
If used without parameters, the n command clears the current specification.
[drive:][path] filename
Specifies the location and name of the executable file to be tested.
file-parameters
Specify parameters and switches for the executable file being tested.
For information on loading the contents of a file or a specified disk sector into memory, see Debug L (Loading).
For information about writing to files debugged to disk, see Debug W (Write).
illustrate
Two uses of n command
The n command can be used in two ways. First, you can use it to specify the file used by the subsequent l (load) or w (write) commands. If Debug is started without naming the debugged file, the command nfilename must be used before loading the file with the l command. In CS:5C, correctly format file names for file control blocks (FCBs). Secondly, you can use the n command to specify the command line parameters and switches of the debugged file.
Memory area
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 Blocks (FCB) for File 2
CS:80
n length of the command line (in characters)
CS:81
n Start of command line characters
The first file name specified for the n command is placed in the FCB of CS:5C. If you specify a second file name, this name will be placed in the FCB of CS:6C. n The number of characters (except the first character, n) typed on the command line is stored at location CS:80. The actual characters on the n command line (again, except for the letter n) are stored at positions starting with CS:81. Note These characters can be any switches and separators that are valid in the commands typed at the Windows 2000 command prompt.
example
Assume that Debug has been started and the program being debugged is loaded. Then you decide to assign two parameters to and run the program. Here is the sequence of commands for this example:
debug
nparam1 param2
g
In this case, the Debug g (steer) command runs the program as if you had typed the following command after the Windows 2000 command prompt:
prog param1 param2
Therefore, testing and debugging reflects the usual runtime environment.
In the following command sequence, the first n command will be specified as the file of the l (load) command followed by, which will be loaded into memory. The second n command specifies the parameters to be used. Finally, the g command will run the file as if you typed File1 in the Windows 2000 command line.
l
g
Notice
Do not use the l command after the second form of the n command. Also note that if you use the w (write) command now, Windows 2000 will use the name to save the file being debugged. To avoid this result, the first form of n command should always be used immediately before the l or w command.
Debug:O (Output)
Sends the byte value to the output port.
o port byte-value
parameter
port
Specify the output port by address. The port address can be a 16-bit value.
byte-value
Specifies the byte value to point to port.
For information on reading byte values from the input port, see Debug I (Input).
example
To send a byte value 4Fh to an output port with address 2F8h, type the following command:
o2f8 4f
Debug:P (Execution)
Execute loops, repeated string instructions, software interrupts, or subroutines; or track them through any other instructions.
p [= address] [number]
parameter
=address
Specifies the first location to execute the instruction. If the address is not specified, the default address is the current address specified in the CS:IP register.
number
Specifies the number of instructions to be executed before returning control to Debug. The default value is 1.
For information about running programs currently in memory, see Debug G (Turning).
For information on executing instructions, see Debug T (tracking).
illustrate
Control the transfer to the program to be tested
When the p command passes control from Debug to the program to be tested, the program runs continuously until looping, repeating string instructions, software interrupts, or completing a subroutine of a specified address, or until a specified number of machine instructions are executed. Control returns to Debug.
Restrictions on address parameters
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 be executed 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, a duplicate string instruction, a software interrupt, or a subroutine, the p command works the same as the Debug t (trace) command.
Emails displayed using the p command
After p executes a paragraph of explanation, Debug displays the program's register content, the status of the flag, and the decoded form of the next paragraph of instructions to be executed.
warn
Read-only memory (ROM) cannot be tracked using the p command.
example
Suppose the program being tested contains a call instruction at address CS:143F. To run the subroutine of the call target location and then return control to Debug, type the following command:
p=143f
Debug displays the results 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 (Exit)
Stop the Debug session and do not save the file of the current test.
After you type q, control returns to the command prompt for Windows 2000.
q
parameter
This command has no parameters.
For information on saving files, see Debug W (Write).
Debug:R (Register)
Displays or changes the contents of one or more CPU registers.
r [register-name]
parameter
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 register name whose contents you want to display.
For information on displaying parts of memory, see Debug D (Dump).
For information about disassembling bytes, see Debug U (disassembly).
illustrate
Use the r command
If a register name is specified, Windows 2000 displays the 16-bit value of the register represented by the hexadecimal marker and displays the 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; otherwise, press ENTER to return to the Debug prompt.
Valid register name
The following are the valid values of register-name: ax, bx, cx, dx, sp, bp, si, di, ds, es, ss, cs, ip, pc and f. Both ip and pc refer to instruction pointers.
If you specify a register name instead of specified from the previous list, Windows 2000 displays the following message:
br error
Use f characters instead of register names
If you type the f character instead of the register name, Debug displays the current setting of each tag as a two-letter code, and then displays a Debug prompt. To change the settings for the flag, type the appropriate two-letter code from the following table:
Logo name
set up
Clear
overflow
ov
nv
direction
dn(reduce)
up (increase)
Interrupt
ei (enabled)
di (disabled)
Positive and negative
ng (negative)
pl (positive)
zero
zr
nz
Auxiliary carry
ac
na
Parity
pe(even verification)
po (odd verification)
Carry out
cy
nc
New flag values can be typed in any order. There is no need to leave spaces between these values. To stop the r command, press ENTER. Any flags that do not specify a new value remain the same.
Emails displayed with r command
If multiple values are specified for the tag, Debug displays the following message:
df error
If you specify that there is no flag code listed in the previous table, Debug displays the following message:
bf error
In both cases, Debug ignores all settings specified after an invalid project.
Debug default settings
When Debug is started, segment registers are set to the low end of free memory, instruction pointer is set to 0100h, all flags are cleared, and the remaining registers are set to zero, except for sp that is set to FFEEh.
Debug:R
example
To view the instruction decoding table of all registers, the status of all markers, and the current location, type the following command:
r
If the current location is CS:11A, the display appearance 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 status of the flag, type the following command:
rf
Debug displays information in the following format:
NV UP DI NG NZ AC PE NC - _
You can now 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 End the r command and displays the Debug prompt. To view 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 for a pattern of one or more byte values in a certain address range.
s range list
parameter
range
Specifies the start and end addresses of the range to be searched.
list
Specifies a pattern for one or more byte values, or the string to search for. Separate each byte value from the next byte value with a space or a comma. Include string values in quotes.
illustrate
If the list parameter contains multiple byte values, Debug will only display the first address where the byte value appears. If list contains only one byte value, Debug displays all addresses in the specified range where the value appears.
example
Assume that you need to find all addresses containing the value 41 and ranging from CS:100 to CS:110. To do this, type the following command:
scs:100 110 41
Debug displays the results 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:T (tracking)
(SORRY, Debug: The T part is currently missing. If any netizen has this part, please notify me)
Debug:U (disassemble)
Disassemble the bytes and display the corresponding primitive statements, including the address and byte values. Disassembly code looks like a list of assembled files.
u [range]
parameter
none
If used without parameters, the u command decomposes 20h bytes (default value), starting from the first address after the address displayed by the previous u command.
range
Specifies the start and end address, or the start address and length of the code to be disassembled.
For information on integrated memory codes, see Debug A (assembly).
For information on displaying parts of memory, see Debug D (Dump).
example
To disassemble 16 (10h) bytes, start with address 04BA:0100, type the following command:
u04ba:100l10
Debug displays the results in the following format:
04BA:0100 206472 AND [SI+72],AH
04BA:0103 69 DB 69
04BA:0104 7665 JBE 016B
04BA:0106 207370 AND [BP+DI+70],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 only information from 04BA:0100 to 04BA:0108 is displayed, type the following command:
u04ba:0100 0108
Debug displays the following:
04BA:0100 206472 AND [SI+72],AH
04BA:0103 69 DB 69
04BA:0104 7665 JBE 016B
04BA:0106 207370 AND [BP+DI+70],DH
Debug:W (write)
Write files or specific partitions to disk.
To write contents that specify the number of bytes in the BX:CX register to a disk file, use the following syntax:
w [address]
To skip the Windows 2000 file system and write directly to a specific sector, use the following syntax:
w address drive start number
parameter
address
Specifies the starting memory address of the file or part of the file to be written to the disk file. If you do not specify address, the Debug program will start at CS:100.
drive
Specifies the drive containing the target disk. This value is numerical: 0 = A, 1 = B, 2 = C, etc.
start
Specifies the hexadecimal number to be written to the first sector.
number
Specifies the number of sectors to be written.
For information about specifying the file used for the w command, see Debug N (name).
For information on loading file or file sector content into memory, see Debug L (Loading).
illustrate
The name of the disk file must be specified when Debug is started or in the most recent Debug n (name) command. Both methods can correctly format the file name of the file control block at address CS:5C.
Reset BX:CX before using the w command without parameters
If the Debug g (steer), t (trace), p (execute), or r (register) commands are used, the BX:CX register must be reset before using the parameterless w command.
Write the modified file to disk
If you modify the file but do not change the file name, length, or start address, Debug can still correctly write the file to the source disk location.
w command limit
This command cannot be used to write to .exe or .hex files.
warn
Because it is skipped with the Windows 2000 file handle, writing to a specific partition is very dangerous. If you type the wrong value, the disk file structure is easily corrupted.
example
Assume that the memory contents with the starting address CS:100 are written to disk on drive B. The data needs to be started from the disk's logical sector number 37h and lasts for 2Bh sectors. To do this, type the following command:
wcs:100 1 37 2b
When the write operation is completed, Debug displays the Debug prompt again.
Debug:XA (allocated extended memory)
The specified number of pages to allocate extended memory.
To use extended memory, you must install the extended memory device driver that complies with the Lotus/Intel/Microsoft Extended Memory Specification (LIM EMS) in version 4.0.
xa [count]
parameter
count
Specifies the number of 16KB pages of extended memory to allocate.
For information about other Debug commands that use extended memory, see Debug XD (Release Extended Memory), Debug XM (Map Extended Memory Page), or Debug XS (Show Extended Memory Status).
illustrate
If the specified number of pages is available, Debug displays a message indicating the hexadecimal number of the handle created; otherwise, Debug displays an error message.
Debug:XA
example
To allocate 8 pages of extended memory, type the following command:
xa8
If the command succeeds, Debug will display a message similar to the following:
Handle created=0003
Debug:XD (release extended memory)
Frees the handle to the extended memory.
To use extended memory, you must install the extended memory device driver that complies with the Lotus/Intel/Microsoft Extended Memory Specification (LIM EMS) in version 4.0.
xd [handle]
parameter
handle
Specifies the handle to be released.
For information about other Debug commands that use extended memory, see Debug XA (Allocate extended memory), Debug XM (Map extended memory page), or Debug XS (Show extended memory status).
example
To release handle 0003, type the following command:
xd 0003
If the command succeeds, 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, you must install the extended memory device driver that complies with the Lotus/Intel/Microsoft Extended Memory Specification (LIM EMS) in version 4.0.
xm [lpage] [ppage] [handle]
parameter
lpage
Specifies the logical page number of the extended memory to be mapped to the physical page ppage.
ppage
Specifies the physical page number to which lpage is mapped.
handle
Specify the handle.
For information about other Debug commands that use extended memory, see Debug XA (Allocation of extended memory), Debug XD (Release of extended memory), or Debug XS (Showing 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 succeeds, Debug will display the following message:
Logical page 05 mapped to physical page 02
Debug:XS (displays extended memory status)
Displays information about extended memory status.
To use extended memory, you must install the extended memory device driver that complies with the Lotus/Intel/Microsoft Extended Memory Specification (LIM EMS) in version 4.0.
xs
parameter
This command has no parameters.
For information about other Debug commands that use extended memory, see Debug XA (Allocate extended memory), Debug XD (Release extended memory), or Debug XM (Mapping extended memory pages).
illustrate
The information displayed by Debug is in 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
This is the end of this article about the detailed explanation of DEBUG command. For more detailed explanation of DEBUG commands, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!