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:9.1; 标签:ow2、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明...
Maven坐标:org.ow2.asm:asm:7.1; 标签:ow2、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和...
asm-1.3.3.jar, asm-1.3.4.jar, asm-1.3.5.jar, asm-1.4.1.jar, asm-1.4.2.jar, asm-1.4.3.jar, asm-1.4.jar, asm-1.5.1.jar, asm-1.5.2.jar, asm-1.5.3.jar, asm-2.0.jar, asm-2.1.jar, asm-2.2.1-sources.jar, asm...
asm字节码jar包,仅需要一个就可以。具体使用,可以参考http://blog.csdn.net/gaoshan12345678910/article/details/78131784
C32Asm是一款非常不错的国产静态反编译工具! C32Asm现具有如下功能: 快速静态反编译PE格式文件(Exe、Dll等) 提供Hex文件编辑功能,功能强大 提供内存Dump、内存编辑、PE文件Dump、PE内存ImageSize修正等多种实用...
asm-analysis-5.0.3.jar;asm-analysis-5.0.3.jar;asm-analysis-5.0.3.jar
ASM,全称是Abstract Syntax Notation One,是一种高级的、基于堆栈的、逆波兰表示法的编程语言,常用于创建低级机器代码,如Intel x86或ARM架构。在计算机科学领域,汇编语言是与特定处理器硬件密切相关的编程语言...
01.ASM:两个5位十进制数相加 02.ASM: 两个字符串的匹配 03.ASM:从键盘输入16进制数,转换为2进制数显示 04.ASM:从键盘输入十进制数,以空格间隔。排序后输出 51.ASM:DOS中断功能实现的ASC2码的表打印、 52.ASM:...
2. C++实现ASM: - C++作为底层语言,可以提供高效和灵活的代码实现,便于优化计算效率。 - 使用OpenCV库,可以方便地处理图像数据,包括读取、预处理、特征提取等操作。 - 在实现ASM时,可能需要定义形状表示...
### asm操作指南(中文)知识点总结 #### 一、ASM框架简介 - **定义与功能**:ASM是一个Java字节码操纵框架,主要用于动态生成类或增强现有类的功能。通过直接生成二进制`.class`文件,ASM能够在类被加载到Java...
标题中的"asm-util.jar.zip"表明这是一个压缩文件,其中包含了ASM工具库的一个实用程序版本。ASM是一个Java字节码操控和分析框架,它能够用来动态生成类或者增强已有类的功能。ASM库通常被用于编译器、代码分析工具...
Maven坐标:org.ow2.asm:asm:4.2; 标签:ow2、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明...
Maven坐标:org.ow2.asm:asm:5.0.4; 标签:ow2、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,...
2. EXP9(AD转换实验).ASM:涉及模数转换(ADC),可能是将模拟信号(如传感器输入)转化为数字信号,以便8255处理。 3. EXP15(步进电机控制实验).ASM:使用8255控制步进电机的运动,展示了8255的输出控制能力。 ...
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”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变...
### asm源码:计算圆周率 #### 概述 本文档介绍了一个使用汇编语言(Assembly Language,简称ASM)编写的程序,该程序的主要功能是计算圆周率π到非常高的精度,即N位(N > 1000000000)的十进制数。作者分享了其...
1. TDO.ASM:TDO可能是指Test Data Out,在某些微控制器中,这是一个用于JTAG调试的信号线,这个文件可能包含与该接口相关的代码。 2. CL.ASM:可能是"Clear"的缩写,这个文件可能包含清除屏幕或LED显示的代码。 3...
Maven坐标:org.ow2.asm:asm:9.1; 标签:ow2、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和...