Sender: liuxf (Flying Sword Flow), Forum: DOS
Subject: Detailed Explanation of Debug Commands
Posted: BBS Tsinghua Station (Mon Apr 23 16:16:59 2001)
Detailed Explanation of Debug Commands
There is no essence area, so I'll post it.
Command Line Parameter Format:
Format: DEBUG filename ]
Purpose: Debug loads the specified file into memory and displays the prompt "-" waiting for further commands. If the loaded file is an.exe file, it is loaded into an executable state according to the relocation principle. The.com file is similar. If it is another type of file, it is directly memory-mapped, and the offset 100H is read into memory as is.
Debug will create an appropriate PSP (Program Segment Prefix) in the buffer for the program being debugged. The offset 80H in the PSP is the end of the command line. Also, the default FCB (File Control Block) is composed of optional parameters after the parameters at offsets 5CH and 6CH.
Initial situation of each register when entering:
Register .com program .exe program
AX Specified drive error code Specified drive error code
BX High address of program space High address of program space
CX Low address of program space Low address of program space
DX 0 0
SI 0 0
DI 0 0
BP 0 0
SP 0FFFFH or the upper limit of available memory space minus 2 Indefinite
IP 100H Offset of the target program's code entry
CS PSP Segment address of the target program's code
DS PSP PSP
CS PSP PSP
SS PSP Bottom of the target program's stack segment
Command:
A: Write Assembly Code (Assemble)
Format: A
Purpose: The program allows assembly writing at the specified position (if there is no default, it is the position of the IP pointer).
Details:
* All values are hexadecimal integers, and the value is not followed by "H"
* Does not support directory tables, macro markers, conditional assembly for file management
* For jump instructions, directly write the hexadecimal address, and labels are not supported
* If the data type is not the default type, it must be specified with PTR
* String operations must specify the type as B or W (such as lodsb and lodsw, etc.) and length
* Use DB and DW to accept data definitions and directly assemble
* Add to the memory address to distinguish it from immediate numbers
C: Compare Memory Contents (Compare)
Format: C address range address
Address range: start and end addresses or start address and length of the first memory area for comparison
Address: Start address of the second memory area for comparison
Purpose: * Compare the contents of two areas in memory, byte by byte. For the content and address where a difference is found, it is displayed in the following form:
Address 1 start position end position address 2
* If the address range or address does not contain the segment address, the value of DS is default.
D: Display Memory Contents (Dump)
Format: D
Address range: Given start and end range or start address and length of the display area.
Purpose: * Memory content display instruction, displaying the memory content within the specified range in hexadecimal and ASCII code form.
* If the range is not specified, the first display starts at the address of CS:IP of the target program. Later, the display starts at the next address of the last displayed end address.
* If the length is not specified, the content of 128 bytes is displayed. There are 8 lines.
E: Input Data
Format: E address value list
Address: Start address of memory for data input
Value list: Continuous data input from the start address
Purpose: * Input data into the memory area. The data can be in hexadecimal form or ASCII code form. Overwrite the original data.
* When in hexadecimal, use spaces, commas, or tabs to separate. The string must be enclosed in single quotes or double quotes and is case-sensitive.
* If the segment address is not specified, the value in DS is default. Each data address is automatically increased after writing.
* If the value list is omitted, each byte is requested to be input. The original value of the byte is before the dot, and input is requested after the dot. At this time, if you press the space, skip this byte; press Enter to end the input; press the minus sign or hyphen to display the previous byte content.
* If there is an error, the memory content may have been changed. The prompt terminates.
* The string can only be input in the form of a value list and cannot be input by address prompt.
F: Fill Memory (Fill)
Format: F address range value list
Address range: start and end address or start address and length of data input
Value list: Continuous data input from the start address
Purpose: * Write the data in the list to the memory. The input data can be in hexadecimal or ASCII code form. Overwrite the original information; if there is an error, display the error message and the original information is retained.
* If the segment address is not specified, the value of the DS register is default.
* The list can have both hexadecimal and string forms, and each content is separated by spaces, commas, tabs. The string must be enclosed in single quotes or double quotes and is case-sensitive.
* If the area to be filled is larger than the number of data, the list can be reused; conversely, if the list is larger than the area to be filled, the subsequent data is automatically truncated.
G: Execute Program (Go)
Format: G
Address: The address where Debug starts to execute.
Breakpoint 0……breakpoint 9: Specified 0-10 temporary breakpoints.
Purpose: * Transfer the CPU control from Debug to the program being debugged. If there are no breakpoints, the program either fails halfway or ends normally. When it ends, it prompts "Program terminated normally", that is, the program ends normally, and the control returns to Debug.
* At this time, because the data may be rewritten, if you need to execute again, you need to reload.
* In the address, if the segment address is not specified, the value in the CS register of the target program is used. When the address is omitted, Debug uses the value of CS:IP register of the target program to start execution. And to distinguish from breakpoints, the address parameter must be preceded by an equal sign, otherwise it is considered as the 0th breakpoint.
* The breakpoint parameter can specify 10 temporary breakpoints. When the program executes to the specified breakpoint address, it will be suspended. Irrespective of the order in the breakpoint table, breakpoints can be entered in any order.
* When suspended, the content of the register, the state of the flag bit, and the instruction pointed to by CS:IP (that is, the next instruction to be executed) will be displayed, and then the prompt "-".
* If no executable program is loaded or the program content is unknown, it may enter a dead state.
* If the stack of the target program is not working or is too small, it may cause the system to "break".
H: Perform Hexadecimal Arithmetic Operations (Hexadecimal)
Format: H value 1 value 2
Values 1 and 2 are any hexadecimal numbers in the range 0-FFFFH.
Purpose: * Used to find the sum and difference of two hexadecimal numbers, and the result is displayed as value 1 + value 2 and value 1 - value 2. If value 2 > value 1, its complement is displayed.
* Although it is rarely used, it is actually very useful, so master it proficiently.
I: Input from Port (Input)
Format: I port address
Port address: I/O port address in the range 0-FFFF.
Purpose: Used to read the specified I/O port address and display it in 2-digit hexadecimal.
Warning: The I instruction will directly access the computer hardware, and not all error checks can be performed, so use it with caution. The input operation of allocating a port to a certain peripheral controller may interfere with the inherent operation of the system. For devices that do not allocate the specified I/O port, or for ports that are dedicated to writing, etc., the I command cannot guarantee to display.
L: Load Command (Load)
Format: L address
Or
L address drive start sector number of sectors
Address: Memory address where the data read from the disk is stored.
Drive: A=0, B=1, C=2, and so on.
Start sector: The logical sector number to be loaded first, expressed in hexadecimal.
Number of sectors: The number of consecutive sectors to be loaded, expressed in hexadecimal.
Purpose: * If an incomplete L command is entered, the following disk file is loaded:
1 The file specified in the Debug command line;
2 The file specified by the command end parameter N.
* If the segment address is not specified in the address, the value in CS is used. If it is an executable file, it is loaded into an executable state according to the relocation principle.
* The length of the loaded file, or the actual length of the.exe file program, is placed in the BX and CX registers of the target program. The high 16 bits are placed in BX.
* If all parameters are given in the command line, there is no need to access the disk using the MS-DOS file system.
M: Data Transfer (Move)
Format: M address range address
Address range: start and end addresses of the copied area, or start address and length.
Address: Start address of the data copy destination area.
Purpose: * Copy data in memory. The destination area is overwritten.
* If there is no segment address in the address range, the content of DS is used; if there is no segment address in the address, the value in the address range is used.
N: File Name or Command End Parameter (Name)
Format: N parameter
Parameter: Insert one or more file names or switch items into the simulated PSP.
Purpose: * Specify the target file for disk read and write operations L and W.
O: Output to Port (Output)
Format: O port byte
Port: I/O port address.
Byte: Value in the range 0-FFFF written to the I/O port.
Purpose: Write a byte to the I/O port address.
Warning: Incorrect operation will cause the system to crash.
P: Loop or Subroutine Processing (Procedure)
Format: P
Address: Start address of execution.
Number of instructions: Number of instruction lines to execute.
Purpose: * Loop or subroutine processing. Treat loops, string instructions, software interrupts, or subroutine calls as a single statement. During execution, the content of the target program register, the state of the flag bit, and the next instruction to be executed are displayed.
* If there is no segment address in the address parameter, the value in CS is used. If the address is completely omitted, execution starts from the position specified by CS:IP in the program.
Q: End Debug Operation (Quit)
Format: Q
Purpose: The program ends and returns. The unsaved results are lost.
R: Display and Change Registers (Register)
Format: R
Register: AX BX CX DX SP BP SI DI
DS ES CS IP PC
F
Purpose: * If R has no parameters, display the contents and status flags of all registers and the next instruction.
* If a new value is specified, after displaying the content, a colon prompt is given to enter the new value. Press Enter to end.
* For the status word F, enter the new value separated by spaces after the hyphen "-", and the order does not matter.
* If you press Enter directly, the modification is skipped and the register content remains unchanged.
S: Memory Search (Search)
Format: S address range list
Address range: I think you should understand what it is like :)
List: One or more byte values or strings to be searched.
Purpose: * Search for the value in the list within the specified memory range. Display each matching address.
* If there is no segment address in the start address, the value of DS is default.
* The search range must not be greater than FFFFH
* The list must be separated by delimiters (spaces, commas, tabs, etc.); the string must be enclosed in single quotes or double quotes and is case-sensitive.
T: Program Execution Trace (Trace)
Format: T
Address: The address of the first instruction to execute.
Number of instructions: Number of machine instructions to execute.
Purpose: * Execute a single instruction and display the register and the next instruction.
* If there is no segment address in the address parameter, the value of the CS register is default.
* If all are omitted, execution starts from the address pointed to by the CS:IP register.
* Then execute in sequence.
* Use the T command for tracing in ROM.
Warning: For the change of the content of the Intel 8259 interrupt screen (IBM PC and compatible machine ports 20H and 21H), or the system function call (INT 21H), the T instruction cannot be used. For the above situations, the P instruction should be used.
U: Disassemble (Unassemble)
Format: U
Purpose: * Decode the machine instruction into the mnemonic of assembly language.
* If there is no segment address in the address range, the value of CS is used by default.
* When the start address is inconsistent with the actual boundary, the result will be unreliable.
* If the end address or length is not included, disassemble 32 bytes starting from the given start address.
* Then disassemble 32 bytes from the next instruction of the last instruction of the previous U.
* If U has never been used, disassemble from CS:IP.
* Only decode 8086 instructions, and display others with DB.
W: Write to File or Sector (Write)
Format: W
Or
W address drive start sector number of sectors
Address: Start position in memory of the data to be written to the disk.
Drive: Drive number of the disk to write data (A=0, B=1, C=2, and so on).
Start sector: The first logical sector number to write data (0-FFFFH).
Number of sectors: Number of consecutive sectors to write data (0-FFFFH).
Purpose: * Transfer the file or sectors in memory to the disk.
* If W has no parameters or only the address parameter, write data from memory to the disk according to the bytes pointed to by the BX:CX register. At this time, the file name is the last file name used before this command, or the file specified in the N command. If the N command is not used, the file specified in the Debug command line is used.
* The W command of Debug cannot write data to files with extensions.EXE or.HEX.
* This can be applied by changing the extension to make it possible to write to.exe files.
* If there is no address item, it is considered as CS:0100H of the target program.
* This command can directly access the logical sector of the disk without passing through the MS-DOS file system. But each parameter must be given in hexadecimal form in the command line.
* The W command cannot process logical sector writing for drives used on the network.
Warning: If the parameters are incorrect, the disk file structure may be damaged.
Please be sure to figure it out before practicing, especially for hard disk operations.
--
※ Source:·BBS Tsinghua Station smth.org·
(Copied using S-Term article copy script)
==================================================
Subject: Detailed Explanation of Debug Commands
Posted: BBS Tsinghua Station (Mon Apr 23 16:16:59 2001)
Detailed Explanation of Debug Commands
There is no essence area, so I'll post it.
Command Line Parameter Format:
Format: DEBUG filename ]
Purpose: Debug loads the specified file into memory and displays the prompt "-" waiting for further commands. If the loaded file is an.exe file, it is loaded into an executable state according to the relocation principle. The.com file is similar. If it is another type of file, it is directly memory-mapped, and the offset 100H is read into memory as is.
Debug will create an appropriate PSP (Program Segment Prefix) in the buffer for the program being debugged. The offset 80H in the PSP is the end of the command line. Also, the default FCB (File Control Block) is composed of optional parameters after the parameters at offsets 5CH and 6CH.
Initial situation of each register when entering:
Register .com program .exe program
AX Specified drive error code Specified drive error code
BX High address of program space High address of program space
CX Low address of program space Low address of program space
DX 0 0
SI 0 0
DI 0 0
BP 0 0
SP 0FFFFH or the upper limit of available memory space minus 2 Indefinite
IP 100H Offset of the target program's code entry
CS PSP Segment address of the target program's code
DS PSP PSP
CS PSP PSP
SS PSP Bottom of the target program's stack segment
Command:
A: Write Assembly Code (Assemble)
Format: A
Purpose: The program allows assembly writing at the specified position (if there is no default, it is the position of the IP pointer).
Details:
* All values are hexadecimal integers, and the value is not followed by "H"
* Does not support directory tables, macro markers, conditional assembly for file management
* For jump instructions, directly write the hexadecimal address, and labels are not supported
* If the data type is not the default type, it must be specified with PTR
* String operations must specify the type as B or W (such as lodsb and lodsw, etc.) and length
* Use DB and DW to accept data definitions and directly assemble
* Add to the memory address to distinguish it from immediate numbers
C: Compare Memory Contents (Compare)
Format: C address range address
Address range: start and end addresses or start address and length of the first memory area for comparison
Address: Start address of the second memory area for comparison
Purpose: * Compare the contents of two areas in memory, byte by byte. For the content and address where a difference is found, it is displayed in the following form:
Address 1 start position end position address 2
* If the address range or address does not contain the segment address, the value of DS is default.
D: Display Memory Contents (Dump)
Format: D
Address range: Given start and end range or start address and length of the display area.
Purpose: * Memory content display instruction, displaying the memory content within the specified range in hexadecimal and ASCII code form.
* If the range is not specified, the first display starts at the address of CS:IP of the target program. Later, the display starts at the next address of the last displayed end address.
* If the length is not specified, the content of 128 bytes is displayed. There are 8 lines.
E: Input Data
Format: E address value list
Address: Start address of memory for data input
Value list: Continuous data input from the start address
Purpose: * Input data into the memory area. The data can be in hexadecimal form or ASCII code form. Overwrite the original data.
* When in hexadecimal, use spaces, commas, or tabs to separate. The string must be enclosed in single quotes or double quotes and is case-sensitive.
* If the segment address is not specified, the value in DS is default. Each data address is automatically increased after writing.
* If the value list is omitted, each byte is requested to be input. The original value of the byte is before the dot, and input is requested after the dot. At this time, if you press the space, skip this byte; press Enter to end the input; press the minus sign or hyphen to display the previous byte content.
* If there is an error, the memory content may have been changed. The prompt terminates.
* The string can only be input in the form of a value list and cannot be input by address prompt.
F: Fill Memory (Fill)
Format: F address range value list
Address range: start and end address or start address and length of data input
Value list: Continuous data input from the start address
Purpose: * Write the data in the list to the memory. The input data can be in hexadecimal or ASCII code form. Overwrite the original information; if there is an error, display the error message and the original information is retained.
* If the segment address is not specified, the value of the DS register is default.
* The list can have both hexadecimal and string forms, and each content is separated by spaces, commas, tabs. The string must be enclosed in single quotes or double quotes and is case-sensitive.
* If the area to be filled is larger than the number of data, the list can be reused; conversely, if the list is larger than the area to be filled, the subsequent data is automatically truncated.
G: Execute Program (Go)
Format: G
Address: The address where Debug starts to execute.
Breakpoint 0……breakpoint 9: Specified 0-10 temporary breakpoints.
Purpose: * Transfer the CPU control from Debug to the program being debugged. If there are no breakpoints, the program either fails halfway or ends normally. When it ends, it prompts "Program terminated normally", that is, the program ends normally, and the control returns to Debug.
* At this time, because the data may be rewritten, if you need to execute again, you need to reload.
* In the address, if the segment address is not specified, the value in the CS register of the target program is used. When the address is omitted, Debug uses the value of CS:IP register of the target program to start execution. And to distinguish from breakpoints, the address parameter must be preceded by an equal sign, otherwise it is considered as the 0th breakpoint.
* The breakpoint parameter can specify 10 temporary breakpoints. When the program executes to the specified breakpoint address, it will be suspended. Irrespective of the order in the breakpoint table, breakpoints can be entered in any order.
* When suspended, the content of the register, the state of the flag bit, and the instruction pointed to by CS:IP (that is, the next instruction to be executed) will be displayed, and then the prompt "-".
* If no executable program is loaded or the program content is unknown, it may enter a dead state.
* If the stack of the target program is not working or is too small, it may cause the system to "break".
H: Perform Hexadecimal Arithmetic Operations (Hexadecimal)
Format: H value 1 value 2
Values 1 and 2 are any hexadecimal numbers in the range 0-FFFFH.
Purpose: * Used to find the sum and difference of two hexadecimal numbers, and the result is displayed as value 1 + value 2 and value 1 - value 2. If value 2 > value 1, its complement is displayed.
* Although it is rarely used, it is actually very useful, so master it proficiently.
I: Input from Port (Input)
Format: I port address
Port address: I/O port address in the range 0-FFFF.
Purpose: Used to read the specified I/O port address and display it in 2-digit hexadecimal.
Warning: The I instruction will directly access the computer hardware, and not all error checks can be performed, so use it with caution. The input operation of allocating a port to a certain peripheral controller may interfere with the inherent operation of the system. For devices that do not allocate the specified I/O port, or for ports that are dedicated to writing, etc., the I command cannot guarantee to display.
L: Load Command (Load)
Format: L address
Or
L address drive start sector number of sectors
Address: Memory address where the data read from the disk is stored.
Drive: A=0, B=1, C=2, and so on.
Start sector: The logical sector number to be loaded first, expressed in hexadecimal.
Number of sectors: The number of consecutive sectors to be loaded, expressed in hexadecimal.
Purpose: * If an incomplete L command is entered, the following disk file is loaded:
1 The file specified in the Debug command line;
2 The file specified by the command end parameter N.
* If the segment address is not specified in the address, the value in CS is used. If it is an executable file, it is loaded into an executable state according to the relocation principle.
* The length of the loaded file, or the actual length of the.exe file program, is placed in the BX and CX registers of the target program. The high 16 bits are placed in BX.
* If all parameters are given in the command line, there is no need to access the disk using the MS-DOS file system.
M: Data Transfer (Move)
Format: M address range address
Address range: start and end addresses of the copied area, or start address and length.
Address: Start address of the data copy destination area.
Purpose: * Copy data in memory. The destination area is overwritten.
* If there is no segment address in the address range, the content of DS is used; if there is no segment address in the address, the value in the address range is used.
N: File Name or Command End Parameter (Name)
Format: N parameter
Parameter: Insert one or more file names or switch items into the simulated PSP.
Purpose: * Specify the target file for disk read and write operations L and W.
O: Output to Port (Output)
Format: O port byte
Port: I/O port address.
Byte: Value in the range 0-FFFF written to the I/O port.
Purpose: Write a byte to the I/O port address.
Warning: Incorrect operation will cause the system to crash.
P: Loop or Subroutine Processing (Procedure)
Format: P
Address: Start address of execution.
Number of instructions: Number of instruction lines to execute.
Purpose: * Loop or subroutine processing. Treat loops, string instructions, software interrupts, or subroutine calls as a single statement. During execution, the content of the target program register, the state of the flag bit, and the next instruction to be executed are displayed.
* If there is no segment address in the address parameter, the value in CS is used. If the address is completely omitted, execution starts from the position specified by CS:IP in the program.
Q: End Debug Operation (Quit)
Format: Q
Purpose: The program ends and returns. The unsaved results are lost.
R: Display and Change Registers (Register)
Format: R
Register: AX BX CX DX SP BP SI DI
DS ES CS IP PC
F
Purpose: * If R has no parameters, display the contents and status flags of all registers and the next instruction.
* If a new value is specified, after displaying the content, a colon prompt is given to enter the new value. Press Enter to end.
* For the status word F, enter the new value separated by spaces after the hyphen "-", and the order does not matter.
* If you press Enter directly, the modification is skipped and the register content remains unchanged.
S: Memory Search (Search)
Format: S address range list
Address range: I think you should understand what it is like :)
List: One or more byte values or strings to be searched.
Purpose: * Search for the value in the list within the specified memory range. Display each matching address.
* If there is no segment address in the start address, the value of DS is default.
* The search range must not be greater than FFFFH
* The list must be separated by delimiters (spaces, commas, tabs, etc.); the string must be enclosed in single quotes or double quotes and is case-sensitive.
T: Program Execution Trace (Trace)
Format: T
Address: The address of the first instruction to execute.
Number of instructions: Number of machine instructions to execute.
Purpose: * Execute a single instruction and display the register and the next instruction.
* If there is no segment address in the address parameter, the value of the CS register is default.
* If all are omitted, execution starts from the address pointed to by the CS:IP register.
* Then execute in sequence.
* Use the T command for tracing in ROM.
Warning: For the change of the content of the Intel 8259 interrupt screen (IBM PC and compatible machine ports 20H and 21H), or the system function call (INT 21H), the T instruction cannot be used. For the above situations, the P instruction should be used.
U: Disassemble (Unassemble)
Format: U
Purpose: * Decode the machine instruction into the mnemonic of assembly language.
* If there is no segment address in the address range, the value of CS is used by default.
* When the start address is inconsistent with the actual boundary, the result will be unreliable.
* If the end address or length is not included, disassemble 32 bytes starting from the given start address.
* Then disassemble 32 bytes from the next instruction of the last instruction of the previous U.
* If U has never been used, disassemble from CS:IP.
* Only decode 8086 instructions, and display others with DB.
W: Write to File or Sector (Write)
Format: W
Or
W address drive start sector number of sectors
Address: Start position in memory of the data to be written to the disk.
Drive: Drive number of the disk to write data (A=0, B=1, C=2, and so on).
Start sector: The first logical sector number to write data (0-FFFFH).
Number of sectors: Number of consecutive sectors to write data (0-FFFFH).
Purpose: * Transfer the file or sectors in memory to the disk.
* If W has no parameters or only the address parameter, write data from memory to the disk according to the bytes pointed to by the BX:CX register. At this time, the file name is the last file name used before this command, or the file specified in the N command. If the N command is not used, the file specified in the Debug command line is used.
* The W command of Debug cannot write data to files with extensions.EXE or.HEX.
* This can be applied by changing the extension to make it possible to write to.exe files.
* If there is no address item, it is considered as CS:0100H of the target program.
* This command can directly access the logical sector of the disk without passing through the MS-DOS file system. But each parameter must be given in hexadecimal form in the command line.
* The W command cannot process logical sector writing for drives used on the network.
Warning: If the parameters are incorrect, the disk file structure may be damaged.
Please be sure to figure it out before practicing, especially for hard disk operations.
--
※ Source:·BBS Tsinghua Station smth.org·
(Copied using S-Term article copy script)
==================================================
Recent Ratings for This Post
( 1 in total)
Click for details
| Rater | Score | Time |
|---|---|---|
| vsbat | +1 | 2010-05-20 16:18 |
ko20010214
=================================
大功告成,打个Kiss!
ko20010214@MSN.com
神州优雅Q300C
Intel CeleronM 370处理器 | 256MbDDR内存
40G硬盘 | USB2.0 | IEEE 1394
13.3 ' WXGA 宽屏(16:10) | COMBO光驱
10/100M网卡 | 四合一读卡器
=================================
大功告成,打个Kiss!
ko20010214@MSN.com
神州优雅Q300C
Intel CeleronM 370处理器 | 256MbDDR内存
40G硬盘 | USB2.0 | IEEE 1394
13.3 ' WXGA 宽屏(16:10) | COMBO光驱
10/100M网卡 | 四合一读卡器

DigestI



