If you have time to write a study note, first note the reference article:
Http://www.cnblogs.com/aguncn/archive/2012/11/14/2769989.html
Http://www.cnblogs.com/aguncn/archive/2012/11/14/2769814.html
http://segmentfault.com/q/1010000000627497
http://blog.csdn.net/herecles/article/details/6080226
My understanding: pointers are indirect addressing using the Mov method. To understand the pointer, you must understand the difference between the Lea and the MOV instructions. And then it feels like it's suddenly enlightened.
The difference between MOV and Lea
MOV ecx,[eax+0x30] means the first operation eax+0x30 get a result, with this result for the address to find a ecx length of memory assigned to ECX
Lea ecx,[eax+0x30] means that the first operation eax+0x30 get a result, the result (MOV address) assigned to ECX
The effect is ecx=eax+0x30 (here EAX participates in the operation but does not change the value)
DWORD Double Word is four bytes
PTR pointer abbreviation is pointer
The data in the [] is an address value, which points to a double-shaped data
For example mov eax, DWORD ptr [12345678] assigns the two-font (32-bit) data in memory address 12345678 to EAX
----------------------------------------------------
The difference between MOV and Lea
It can be said that MOV this assembly instructions in the assembly language program is very very common in an instruction. Make the simplest analogy, like I
People want to talk every day like that. In assembly language, the Mov instruction is like our people speak every day. Every program is inseparable from Mov
Instructions.
MOV instructions:
Transfer instructions, which can be used to transmit registers or to transmit memory addresses.
LEA directive:
Transfer instructions.
If it is just learning assembly language friends, see the above explanation will be very confused, Mov and Lea are transfer instructions, then they straight
Where is the difference between the next?
The differences between Mov and LEA Assembly instructions are explained in detail below.
Give an example of life, for example, if you want to go to the cinema by car, you can tell the driver the address of the cinema, and then the driver will send you according to the address
to the cinema. You can also tell the driver the name of the cinema, and the driver will send you to the cinema by name. We can do it both ways.
Get to the cinema where you want to go.
The role of Mov and Lea is the same as shown in the example above. In different ways (transfer mode), to achieve the same purpose (transmission of data). In other words,
Said, the Mov instruction transmission method, is to store the memory data address to transmit. The LEA, on the contrary, is directly transmitting memory data
Handed.
Here's an example of how Lea differs from MOV:
MOV ecx,30
Add Ecx,eax
====================================================
Lea Ecx,[eax+30]
====================================================
MOV ecx,[eax+30] represents the first operation Eax+30 get a result, with this result for the address passed to a ECX length memory address storage ecx
Lea Ecx,[eax+30] means that the first operation Eax+30 get a result and pass the result to ECX. Equivalent to Ecx=eax+30
Hopefully this article will help friends who are fretting about the difference between MOV and Lea. This article takes 2 nights to finish typesetting and finishing.
1. The right value of MOV must be a constant, not an expression, such as can write Mov EAX, EBP, but can not write mov EAX, EBP + 8
This is because EBP + 8 itself needs an instruction to calculate, so it cannot be written in an instruction with Mov.
2. Note that arithmetic operations can be done within the memory address character [] of the assembly instruction, because the computation of the memory address is handled by the dedicated processing unit AGU in the CPU, and does not occupy the clock cycle of the Alu of the arithmetic unit. However, if the memory address symbol [] is connected with the MOV, the contents of the memory pointed to in the [] will be taken out and put into the register. For example mov eax,[ebx+ecx*4h-20h], will ebx+ecx*4h-20h the results of the calculation as a memory address, and then go to the memory to take the contents of the address to EAX.
3. What if we just want to get the results of arithmetic operations? The LEA command can be used at this time. Since the LEA is followed by a memory address symbol [], the address, not the contents of the address, is fed into the register. For example, if we want to calculate the results of ebx+ecx*4h-20h, we can write this: Lea eax,[ebx+ecx*4h-20h]. Of course it can be done without the LEA instructions, but it would be more troublesome to write: Imul ecx, 4 add ebx, ecx sub ebx, 20h mov eax, ebx
assembly Language Understanding Pointers