x86组装中的LEA

use*_*614 5 x86 assembly

我正在学习x86汇编,并且在lea指令上遇到了一些麻烦。

 0x080486f7 <+21>:  lea    eax,[esp+0x18]
Run Code Online (Sandbox Code Playgroud)

谁能解释这行发生了什么?以我的理解,它将值取为[esp + 0x18]并将其解释为地址,然后将整数地址的值放入eax。

hig*_*aki 5

基本上

mov eax, [esp+0x18]
Run Code Online (Sandbox Code Playgroud)

手段

mov eax, esp
add eax, 0x18
mov eax, [eax]
Run Code Online (Sandbox Code Playgroud)

在C中看起来像

eax = *(unsigned int*)(esp + 0x18)
Run Code Online (Sandbox Code Playgroud)

与此同时

lea eax, [esp+0x18]
Run Code Online (Sandbox Code Playgroud)

手段

mov eax, esp
add eax, 0x18
Run Code Online (Sandbox Code Playgroud)

在C中看起来像

eax = esp + 0x18
Run Code Online (Sandbox Code Playgroud)


Sti*_*sis 1

它存储esp + 0x18eax. 换句话说,这只是加法。LEA 经常用于执行基本算术。

  • 我确信 asm 中不存在滥用行为。 (3认同)