LEAL: leal S, D ? ?-> ? ?D ← &S
在 CSAPP (Computer Systems: A Programmer’s Perspective) 中,對(duì) LEAL 指令用作簡單算術(shù)運(yùn)算的情況,給出了一個(gè)例子:
For example, if register %edx contains value x, leal 7(%edx,%edx,4), %eax will set register %eax to 5x + 7.
正確理解邏輯為:
1. 設(shè)%edx的值為x
2. 7(%edx,%edx,4) 為變質(zhì)尋址,目標(biāo)內(nèi)存地址為5x+7
3. 設(shè)儲(chǔ)存在地址5x+7的值為y。然而LEAL并不尋址,它只取y的地址。y的地址即為5x+7。因此,LEAL的左操作數(shù)為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實(shí)現(xiàn)了簡單算術(shù)功能。