gas: too many memory reference

冷暖自知 提交于 2019-12-17 09:59:55

问题


When compiling the following instruction:

movl 4(%ebp), 8(%ebp)

I got: too many memory reference.

What's wrong with it?


回答1:


The number before the parenthesis is a byte offset (which causes a memory reference to occur), and you cannot have two of them with movl. You need to move the value temporarily to a register first.

movl 4(%ebp), %ecx
movl %ecx, 8(%ebp)



回答2:


It is not a legal instruction. For most instructions that reference memory you must move it to/from a register.




回答3:


movl doesn't to memory-memory moves, you have to go by way of a register (thus with two movl instructions).



来源:https://stackoverflow.com/questions/2531682/gas-too-many-memory-reference

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!