1 / 26

Assembly Language Programming Part 3

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.

Download Presentation

Assembly Language Programming Part 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Debugger Debug Subcommands Writing and Executing Assembly Code Using Debugger Assembly Language Programming Part 3

  2. 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

  3. How to use Debug

  4. How to use Debug Type cmd (command Line)

  5. How to use Debug This Local path changes from one computer to another

  6. 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

  7. 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

  8. 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

  9. 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).

  10. 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.

  11. 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).

  12. 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

  13. 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

  14. 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

  15. How to use Debug mov al,2 is typed instead of mov ah,2

  16. 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.

  17. 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

  18. 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

  19. 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)

  20. 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)

  21. 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”)

More Related