Program Execution Process Tracking: (use DEBUG to track the running process of a program) sort out and summarize

Source: Internet
Author: User

1. Reason: run Program The command loads the program executable files into the memory,
And executed. However, we do not see the process of gradual execution of the program, because the command program loading and setting Cs: IP points to the program's entry operations are completed consecutively, and when Cs: once the IP address points to the program entry, the command gives up control of the CPU, and the CPU immediately starts executing the program until the program ends.
2. Purpose: To observe the Program Execution Process, debug can be used. Debug can load the program into the memory and set the Cs: IP address execution program entry. However, debug does not give up CPU control, so you can use DEBUG to gradually execute the program.
3 method:
(1) Enter debug target.exe at the prompt, and press the enterkey to load the program target.exe to the memory, initialize the line, and set Cs: IP to the entry of the program.
(2) run the R command to view the values of each register. We can see that the length of the program is stored in CX.
(3366dossystem. Here we mainly understand why the program address is set to SA + 10 h: 0. below is my understanding: in step 2 in Figure 4.20, it has the following sentence: In the first 256 bytes of the memory area, the PSP data zone is created. In the third step, the program is loaded from the 256 bytes of the memory area. The starting address of this memory zone is SA, and 256 bytes of memory are occupied, while 256 is represented as 100 h in hexadecimal notation and 10 h in offset Notation: 0. The value is 1x16x16 = 256 in decimal format. To sum up, the program address is set to SA + 10 h: 0. In fact, the key here is to see 10 h: 0 = 0100 H, at the same time 10 h: 0 is a whole. It may be clearer: (10 h: 0) + SA ). Therefore, the Cs: IP value is (10 h: 0) + SA), and the last segment is placed in DS, that is, DS = sa.
(4) Next, you can use the commands in debug, such as R, T, A, U, to debug the program. However, when int 21 is executed, the p command should be used for execution, then the program stops normally.
(5) The order in which the program is loaded using debug is commandincludebug,debug+target.exe. The returned order is: from the program in target.exe to debug, from debug to command.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.