正确理解 LEAL (Load Effective Address) 指令

LEAL: leal S, D    ->    D ← &S

在 CSAPP (Computer Systems: A Programmer’s Perspective) 中,对 LEAL 指令用作简单算术运算的情况,给出了一个例子:

For example, if register %edx contains value x, leal 7(%edx,%edx,4), %eax will set register %eax to 5x + 7.

正确理解逻辑为:

1. 设%edx的值为x

2. 7(%edx,%edx,4) 为变质寻址,目标内存地址为5x+7

3. 设储存在地址5x+7的值为y。然而LEAL并不寻址,它只取y的地址。y的地址即为5x+7。因此,LEAL的左操作数为5x+7

CSAPP描述为:

It has the form of an instruction that reads from memory to a register, but it does not reference memory at all. Its first operand appears to be a memory reference, but instead of reading from the designated location, the instruction copies the effective address to the destination.

4. LEAL将y的地址,5x+7,赋给%eax

至此,LEAL实现了简单算术功能。



文/WhiteWhite_iOS(简书作者)
原文链接:http://www.jianshu.com/p/29ce0edcd975
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

转载于:https://www.cnblogs.com/thrillerz/p/5779327.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值