Move smaller operand into larger operand

亡梦爱人 提交于 2019-12-11 17:01:20

问题


I'm having a little trouble with imagining how data moves into the RAX register.

Here is the assembly language:

.data
dwordVal DWORD 94326732h
.code
mov rax, 0FFFFFFFF00000000h
mov rax, dwordVal

I read that you cannot move a smaller operand into a larger operand with MOV. It seems to me that dwordVal would only fill the lower half of the 64 bit rax register, so this would not be permitted. Please correct me if I'm wrong.


回答1:


A mov instruction will always fill the destination operand with a complete value, of exactly the same size as the destination operand.

So, your understanding is incorrect. You cannot fill part of rax with a mov.

As Jester has already said in a comment, precisely what will happen as a result of that mov rax, dwordVal depends on the conventions followed by your assembler, and some assemblers would actually reject such a thing as illegal.

One thing I can tell you is that there will be absolutely nothing left in rax from that 0FFFFFFFF00000000h that was previously loaded into it.



来源:https://stackoverflow.com/questions/48449833/move-smaller-operand-into-larger-operand

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