Use of basic commands DEBUG [MASM]

DEBUG using the basic commands of

DEBUG is dedicated to the compilation of debugging a language design tool, it is through stepping, setting breakpoints, etc. provide very effective debugging tool for assembly language programmers.

DEBUG command is a letter followed by one or more parameters: letters  [ parameters ]

Use the command of note:

①  letters are not case sensitive;

②  only use 16 hexadecimal numbers, no suffix letter;

③  separators (comma or space) between the two values is only necessary, commands and parameters can be no inter-separator;

④  each command is only valid after pressing the Enter key, you can use Ctrl + Break execution abort command;

⑤  command if you do not meet the Debug rules will be to "error" prompt and use "^" indicates the error position.

Many parameters of the command logical address in main memory, in the form of a " base address  :  offset address " . Wherein the base address value or may be a segment register; address offset value. If no segment address, the default value may be a default segment register values. If no offset is usually the current offset.

Command to main memory address range also support operations such parameters, it is in the form of: " the start address end address " (having the segment address is not the end address), or: " Start Address  L byte length " . 

DEBUG command at a glance:

classification

Command Format

Features

Write registers

R

Displays the current contents of all registers

R register name

Display and modify the contents of the specified register

RF

Display and modify the contents of the flag register

Compilation and disassembly

A [ Memory Address ]

Assembly instructions from the specified address

U [ memory blocks ]

The specified memory block to disassemble

Executing instructions

T [ : memory address ] [ number of ]

Single or multi-step execution instruction (entry procedure)

P [= Memory Address ] [ section number ]

Single or multi-step execution instruction (no entry procedure)

G [= Memory Address ]

Continuous execution of instructions

G [= Memory Address ] breakpoint address

Set breakpoints execution procedures

Read-write memory

D [ memory blocks ]

Displays the current memory block contents

E memory address value or character string

Modify the specified memory contents

F memory block character or numeric string

Specified memory block is filled

S memory block or string value

Find string specified memory block

M memory blocks 1 memory block 2 first address

Copy the contents of the memory block

C memory block 1 memory block 2 first address

Comparison of two memory blocks specified

Disk read and write

N [D : ] [path] file name . Extension

To specify read and write disk files

W memory address

The specified memory block to write the file

L [ memory address ]

The files transferred to memory

Read and write I / O ports

I port address

Read the contents of the specified port

O port address value

The data is written to the specified port

Hexadecimal subtraction

H value a value of 2

Calculates and displays two numbers, the difference between two numbers

Quit DEBUG

Q

Exit DEBUG , return to DOS

1, start the DEBUG program

In the DOS prompt, type the command:

C:\>DEBUG↙

DEBUG full format command is: DEBUG [d:] [path] [filename] [Parameter 1] [parameter 2]. Wherein [d:] is the drive letter, [path] is the path, the file name is the name of the debug file, that file must be executed (the EXE), two parameters are being run debugging command parameters required document, in DEBUG after the program transferred, the prompt appears "-" in this case, type the command DEBUG.

At the start when DEBUG, if you enter the file name, the DEBUG program to the specified file into memory. Users can make changes to the file specified by the command DEBUG, display and execution. If no file name is based on the current contents of memory work, or use named commands and command load the necessary files into memory, then use DEBUG command to modify, display and execution.

2, DEBUG major command

(1), inspect and modify the contents of the command register R, which in three ways:

1) all show the internal CPU registers and the contents of status flags, the format is: -R

For example: Enter -R↙, to give the following results:

 

2) a display and modify the contents of the register specified in the format: -R register name

For example: Enter -R AX, to give the following results:

 

Represents AX current content 0000, at this time if its modification, press the ENTER key, otherwise, the input content, such as:

The AX 0000 changed by the content 0A0A

3) R command to display the meaning of the status flag register flag bit in the following table:

Flag Name

Set (value 1)

Reset (value 0)

Overflow Overflow (Yes / No)

OV

NV

The direction of the Direction (decrement / increment)

DN

UP

Interrupt Interrupt (allow / block)

NO

OF

Sign Sign (negative / positive)

OF

PL

Zero Zero (Yes / No)

ZR

NZ

Auxiliary carry Auxiliary Carry (yes / no)

AC

NA

Parity Parity (even / odd)

ON

PO

Carry Carry (yes / no)

CY

NC

Modify the flag state, the command format is: -RF

例如:输入-RF,输出结果如下:

 

这时若不作修改可按ENTER键,否则在“-”号之后键入修改值,键入顺序任意。如:

 

(2)、汇编命令A,格式为:-A[地址]

该命令从指定地址开始允许输入汇编语句,把它们汇编成机器代码相继存放在从指定地址开始的存储器中。A命令中如果没有指定地址,则接着上一个A命令的最后一个单元开始;若还没有使用过A命令,则从当前CS : IP开始。

例如:输入代码,则代码存储在OAFO:0100至OAFO:010D单元中。

 

(3)、反汇编命令U,有两种格式:

1)-U[地址]

该命令从指定地址开始,反汇编32个字节,若地址省略,则从上一个U命令的最后一条指令的下一个单元开始显示32个字节。

 

2)-U范围

该命令对指定范围的内存单元进行反汇编,例如:

-U 0100 011E或-U 100 11E 或-U 0AF0:0100 011E或–U 0AF0:0100 L1F(L用来引导指令的条数,1F为指令的条数),这些命令是等效的。

 

 

(4)、运行命令G,格式为:

-G [=地址1][地址2]

其中地址1规定了运行起始地址,后面的地址为断点地址。若省略地址,则运行从IP所指的地址开始。例如:

 

(5)、追踪命令T,有两种格式:

1)逐条指令追踪:

-T

该命令从指定地址起执行一条指令后停下来,显示寄存器内容和状态值。例如:

 

2)多条指令追踪:(有问题)

-T[=地址][值]

该命令从指定地址起执行n条命令后停下来,n由[值]确定。

(6)、显示内存单元内容的命令D,格式为:

-D[地址](从给出的地址开始连续显示128个字节的单元内容)或-D[范围],例如:

 

(7)、修改内存单元内容的命令E,它有两种格式:

1)用给定的内容代替指定范围的单元内容:

-E地址  内容表

 例如:-E 2000:0100  F3 “XYZ” 8D

其中F3,“X”“Y”“Z”和8D各占一个字节,用这五个字节代替原内存单元2000:0100到0104的内容,“X”“Y”“Z”将分别按它们的ASCII码值代入。

 

2)逐个单元相继地修改:

-E地址

例如:-E 100:

0AF0:0100 F3.E7

此命令是将原100号单元的内容F3改为E7。E7是键入值。

 

(8)、命名命令N,格式为:

-N 文件名

此命令将文件名格式化在CS:5CH的文件控制块内,以便使用L或W命令把文件装入内存进行调试或者存盘。例如:

 

(9)、装入命令L,它有两种功能:

1)把磁盘上指定扇区的内容装入到内存指定地址起始的单元中,格式为:

-L  地址  驱动器  扇区号  扇区个数

2)装入指定文件,格式为:

-L [地址]

此命令装入已在CS:5CH中格式化的文件控制块所指定的文件。

在用L命令前,BX和CX中应包含所读文件的字节数。

3)装入已在文件控制块中的文件,格式为:

-L

此命令与-L [地址]相同功能。

(10)、写命令W,有两种格式:

1)把数据写入磁盘的指定扇区:

-W  地址  驱动器  扇区号  扇区数

2)把数据写入指定文件中:

-W  [地址]

此命令把指定内存区域中的数据写入由CS:5CH处的FCB所规定的文件中。在用W命令前,BX和CX中应包含要写入文件的字节数。

(11)、十六进制运算命令H,格式为:

H [数据1] [数据2]

其功能是将两个十六进制数进行相加、相减运算,结果显示在屏幕上。例如:

 

(12)、退出DEBUG命令Q,该命令格式为:

-Q

它退出DEBUG程序,返回DOS,但该命令本身并不把在内存中的文件存盘,如需存盘,应在执行Q命令前先执行写命令W。

 

附二.DEBUG32的重要扩展命令的使用

1)、R16/R32更换寄存器显示位数命令

  R16 设置 16 bit 显示模式

 

  R32设置 32 bit 显示模式

 

 

2CLS清屏命令

Guess you like

Origin www.cnblogs.com/dgwblog/p/11857976.html