这是函数的前四行。我知道前两行在堆栈中创建一个新框架,基本上是“设置”行。lea 指令有什么作用?
40148e: 48 83 ec 18 sub $0x18,%rsp
401492: 48 89 f2 mov %rsi,%rdx
401495: 48 8d 4e 04 lea 0x4(%rsi),%rcx
401499: 48 8d 46 14 lea 0x14(%rsi),%rax
Run Code Online (Sandbox Code Playgroud)
lea,加载有效地址,将计算出的“内存地址”放入结果寄存器中。所以这里,rcx = rsi + 4和rax = rsi + 0x14。
顺便说一句,第二行看起来并不像是设置堆栈帧的代码的一部分,rsi而是使用 System V AMD64 调用约定时的第二个参数。