270 likes | 288 Views
Windows Debugger Debug Subcommands Writing and Executing Assembly Code Using Debugger. Assembly Language Programming Part 3. Notes. CS is the default segment for the following debug subcommands: a , g , l , t , u and w . DS is the default segment for all subcommands.
E N D
Windows Debugger Debug Subcommands Writing and Executing Assembly Code Using Debugger Assembly Language Programming Part 3
Notes • CS is the default segment for the following debug subcommands: a, g, l, t, u and w. • DS is the default segment for all subcommands. • All numeric values are in hexadecimal format. • You must include a colon between the segment name and the offset value. • Example: • The following are valid addresses: • CS:0100 • 04BA:0100
How to use Debug Type cmd (command Line)
How to use Debug This Local path changes from one computer to another
How to use Debug Write debug then hit enter This prompt indicates that debug is ready to accept commands, always remember that no assembly instructions are accepted when this prompt is shown up
How to use Debug Debug command a<assemble> followed by offset 100 (CS:0100) 0100 is the chosen offset number (specified by the programmer as part of a command), it indicates where your assembly instructions resides within the code segment in main memory 0AE2 is the Code Segment Number which is stored in register CS
How to use Debug Simple program that uses the instruction MOV to set register AL to 1 and Register AH to 2 Notice that, to exit instruction entering mode don’t type any thing and hit enter, you should see the dash prompt again which indicates that you can type debug instructions
How to use Debug To run your program you should use g <go> command, without it, your code will remain in memory, but nothing would actually happen (Register AL and AH would keep their old values). After executing your program, a list of registers and the values they are holding are displayed. Our program only deals with two registers AL and AH. AL and AH together forms the register AX. From the register list AX = 0201(the first two bytes represents AH and the second two bytes represents AL).
How to use Debug Segment Registers DS <Data Segment>, ES <Extra Segment>, SS<Stack Segment>, and CS <Code Segment> are all set to one segment 0AE2 (normally they point to different segments but for simplicity debug use one segment for all of them) which means that you should be careful not to overlap your code with any existing data that is present in that segment.
How to use Debug IP <Instruction Pointer> a special purpose register that holds part of the logical address (offset) of the instruction to be executed (the full logical address is IP:CS).
How to use Debug These are some of the individual bit values that resides within the FLAGS register. They reflect some event that my occur while the execution of your program like arithmetic overflow and division by zero
How to use Debug These are some of the individual bit values that resides within the FLAGS register. They reflect some event that my occur while the execution of your program like arithmetic overflow and division by zero
How to use Debug Debug command u <unassemble>, which displays the machine code (in hexadecimal) corresponding to the assembly instructions in the memory range you specify. B001 is the machine code (in hex) corresponding to the assembly instruction mov al,01. In the same way B402 corresponds to mov ah,2
How to use Debug mov al,2 is typed instead of mov ah,2
How to use Debug To correct this line after it is already been written to memory, simply type nothing and hit enter. Now next to the dash prompt type a102 (CS:0102 is the address of the instruction to be replaced ). Now you can run your program and every thing will work fine.
How to use Debug Debug command r <register> display a list of known registers and their current values. Default value for IP <Instruction Pointer> is 0100. All offsets from 0000 to 00FF are reserved by the operating system. When command r is followed by register e.g. rAX the value within this specific register is displayed then a colon “:”prompt is displayed which allow you to change the value within the register, if left blank no change is applied to the register
How to use Debug 8-bit registers are not accessed via debug command r. You must use assembly instructions in order to change the value within them
How to use Debug Letters String Numbers (in hex) Debug command e <enter> which is used to enter data into specific memory address (in this example DS:0200)
How to use Debug String (hex ASCII code) Since numbers 1,2,A, and E are not representing ASCII code of a character, a dot is displayed. Letters (hex ASCII code) Numbers (in hex) Debug command d <dump> which is used to dump the content of specific memory address range (in this example DS:0200 DS:020a)
How to use Debug Debug command f <fill> which is used to enter a pattern of data into specific range of memory address (e.g. DS:0100 DS:0104 and the pattern is “1,2”)