assembly language, using registers This book has already talked about why we use variables-because we store data when we program. We've also learned that in assembly language, we store data in registers and memory spaces.
Let's explore how registers and memory spaces are used in the C language.
1, first in the C:\minic directory of Tc.exe write a ur1.c program
Compile, link into ur1.exe
2, with debug load Ur1.exe, with u command to view ur1.c compiled machine code and assembly code
Based on the experience of our assembly language learning, the main function code should be stored in the Code section, we can be disassembled by the main function to find the corresponding codes.
Then use the R command to view CS
CS=0D6C verified the conjecture.
It needs to be pointed out here that the main function code needs to be carefully looked up and found the same as the UR1 code to confirm the found
3. Print Ur1.exe is loaded and run, the offset address of main
We add the code content after the above program, compile, link and run
As can be seen, the program has the result of generating
According to the experience we have learned, main is equivalent to a label in assembly language, and when we print it prints out its entry address.
4, use Debug to find the corresponding code
Here is a MOV ax,01fa is not in our previous program, it can be assumed that this is the main entrance address to 01FA and our previous operation results more confirmed this conjecture.
5. Study another program to verify our conjecture
Loading the EXE program with debug
Find the appropriate program
Here we can easily see that there is a call command to find the code at 020B as follows:
Here is the entry of the F (void) function below the RET equivalent to the return of the function
So, it's easy to know that when a function is called in C, it is translated into the corresponding assembly code with the call command, and the program ends back with a ret instruction, which is the same as the assembly language we learned before.
+
@yujin753
2015-02-28 22:30
字数 708
阅读 0
xloading the article picture, please wait a moment ...
Assembly Language---using registers