The difference between LEA and MOV is roughly equivalent to the use of
the "&" operator in C. Specifically:
; eax = &A;
lea eax, A
; eax = A;
mov eax, A
Cheers,
Randy Hyde
TkW wrote:
Ok.
MOV A, EAX <- Moves the value pointed in the address
Depends on the declaration of A. If defined as follows:
A dword ?
Then the mov instruction above moves a copy of the value held in EAX
into the memory location associated with the variable A.
But what about:
MOV A, [EAX] ?
If A is a memory location, defined as above, this is an illegal
instruction. You cannot move the contents of one memory location (e.g.,
the dword at the address held in the EAX register) into another memory
location (A).
This instruction, for me, seems to be same as LEA A, EAX.
This is not a syntactically correct instruction.
LEA eax, A
is okay, which loads the address of the A variable into EAX.
My biggest doubt is with parentheses.
When brackets surround a 32-bit register, this implies *indirection*.
That is, the register's value (EAX's value in this case) is a 32-bit
address of some other object in memory and the instruction uses that
address to reference memory. If the brackets are not present, then
this tells the assembler to use the value of the register directly.
E.g.,
mov ebx, 12345678h
mov eax, ebx ;Loads eax with a copy of EBX's value (12345678h)
mov eax, [ebx] ;Loads eax with the dword at address 12345678h in
memory.
The difference between LEA and MOV is roughly equivalent to the use of
the "&" operator in C. Specifically:
; eax = &A;
lea eax, A
; eax = A;
mov eax, A
Cheers,
Randy Hyde
http://kerneltrap.org/node/51523
The Difference between LEA and MOV OFFSET
on January 23, 2010 - 10:33am
The other day a friend of mine asked me to
code a decimal-to-hex-converter in MASM using DOS ISRs (Interrupt
Service Routine) for I/O. Well, I just gave her the equivalent C code
since I am not into proprietary software. But, anyway I googled for some
materials related to MASM syntax and DOS ISRs for I/O [0]. Upon reading
some examples of using DOS ISR 21h, I stumbled upon the use of LEA
dx, var
and MOV dx, OFFSET var
. So, I decide to
have a look into them and come up with the following conclusion.
First, the keyword OFFSET is not an x86 instruction. It is a keyword
in MASM to take the address of a variable [1][2]. In C, the OFFSET
keyword of MASM is the equivalent of &
in, for example,
scanf("%d", &var)
.
Second, for the simplest case of moving an address into a register,
the following instructions have the same effect [3][27]:
mov dx, offset var
lea dx, var
Finally, in addition to its original purpose of doing pointer
arithmetic, however, LEA can be harnessed to perform integer addition
and multiplication in a way that is faster than using ADD and MUL [4]
and in a way that allows the result to be stored in a register other
than the source register [5].
分享到:
相关推荐
我学习spring程序,测试程序时.老出bug, 后来从网上找原因说asm.jar版本太低 现把好不容易找来的jar包共享给大家
Maven坐标:org.ow2.asm:asm:5.0.4; 标签:ow2、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,...
asm-analysis-5.0.3.jar;asm-analysis-5.0.3.jar;asm-analysis-5.0.3.jar
Maven坐标:org.ow2.asm:asm:7.1; 标签:ow2、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和...
C32Asm是一款非常不错的国产静态反编译工具! C32Asm现具有如下功能: 快速静态反编译PE格式文件(Exe、Dll等) 提供Hex文件编辑功能,功能强大 提供内存Dump、内存编辑、PE文件Dump、PE内存ImageSize修正等多种实用...
01.ASM:两个5位十进制数相加 02.ASM: 两个字符串的匹配 03.ASM:从键盘输入16进制数,转换为2进制数显示 04.ASM:从键盘输入十进制数,以空格间隔。排序后输出 51.ASM:DOS中断功能实现的ASC2码的表打印、 52.ASM:...
asm字节码jar包,仅需要一个就可以。具体使用,可以参考http://blog.csdn.net/gaoshan12345678910/article/details/78131784
汇编笔记仓库
Maven坐标:org.ow2.asm:asm:9.1; 标签:ow2、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明...
ASM是一个java字节码操纵框架,它能被用来动态生成类或者增强既有类的功能。ASM 可以直接产生二进制 class 文件,也可以在类被加载入 Java 虚拟机之前动态改变类行为。Java class 被存储在严格格式定义的 .class...
Maven坐标:org.ow2.asm:asm:4.2; 标签:ow2、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明...
标签:asm-util.jar.zip,asm,util,jar.zip包下载,依赖包
Maven坐标:org.ow2.asm:asm:7.1; 标签:ow2、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明...
Maven坐标:org.ow2.asm:asm:6.0; 标签:ow2、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明...
Maven坐标:org.ow2.asm:asm:6.2.1; 标签:ow2、asm、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变...
Maven坐标:org.ow2.asm:asm:9.1; 标签:ow2、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和...
MIPS_asm:MIPS组装课程
This volume of the ASM Handbook series, Fatigue and Fracture, marks the first separate Handbook on an important engineering topic of long-standing and continuing interest for both materials and ...
asm:随机asm文件的存储库
自己写的主动形状模型,主要使用c++实现的,依赖opencv的开源图像库