“leal 0x10(%ebx), %eax"中的0x10是什么?x86汇编指令? [英] What is the 0x10 in the "leal 0x10(%ebx), %eax" x86 assembly instruction?

查看:33
本文介绍了“leal 0x10(%ebx), %eax"中的0x10是什么?x86汇编指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于这条 LEAL 指令,0x10 的功能是什么?是乘法还是加法还是别的什么?

What the function is of the 0x10 in regards to this LEAL instruction? Is it a multiply or addition or is something else?

leal 0x10(%ebx), %eax

有人可以澄清一下吗?这是 Linux 机器上的 x86 汇编程序.

Can someone please clarify? This is x86 assembler on a Linux box.

推荐答案

leal 或 lea 的全称是加载有效地址",它的作用正是如此:它进行地址计算.

leal, or lea full name is "Load effective address" and it does exactly this: It does an address calculation.

在您的示例中,地址计算非常简单,因为它只是将偏移量添加到 ebx 并将结果存储在 eax 中:

In your example the address calculation is very simple, because it just adds a offset to ebx and stores the result in eax:

eax = ebx + 0x10

eax = ebx + 0x10

lea 可以做的更多.它可以添加寄存器,将寄存器与常量 2、4 和 8 相乘,用于字、整数和双精度数的地址计算.它还可以添加偏移量.

lea can do a lot more. It can add registers, multiply registers with the constants 2, 4 and 8 for address calculations of words, integers and doubles. It can also add an offset.

请注意 lea 的特殊之处在于它永远不会修改标志,即使您像上面的示例一样将其用作简单的添加.编译器有时会利用此功能并用 lea 替换添加项以帮助调度程序.出于这个原因,在编译代码中看到 lea 指令执行简单算术的情况并不少见.

Note that lea is special in the way that it will never modify the flags, even if you use it as a simple addition like in the example above. Compilers sometimes exploit this feature and replace an addition by a lea to help the scheduler. It's not uncommon to see lea instructions doing simple arithmetic in compiled code for that reason.

这篇关于“leal 0x10(%ebx), %eax"中的0x10是什么?x86汇编指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆