MOV src dest (or) MOV dest src?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 11:06:34

问题


MOV is probably the first instruction everyone learns while learning ASM.

Just now I encountered a book Assembly Language Programming in GNU/Linux for IA32 Architectures By Rajat Moona which says:

alt text http://i.imagehost.org/0897/mov.gif

But I learnt that it is MOV dest, src. Its like "Load dest with src". Even Wiki says the same.

I'm not saying that the author is wrong. I know that he is right. But what am I missing here?

btw.. he is using GCC's as to assemble these instructions. But that shouldn't change the instruction syntax right?


回答1:


mov dest, src is called Intel syntax.

mov src, dest is called AT&T syntax.

UNIX assemblers including the GNU assembler uses AT&T syntax, all other x86 assemblers I know of uses Intel syntax. You can read up on the differences on wikipedia.




回答2:


Yes, as/gas use AT&T syntax that uses the order src,dest. MASM, TASM, NASM, etc. all use the order 'dest, src". As it happens, AT&T syntax doesn't fit very well with Intel processors, and (at least IMO) is a nearly unreadable mess. E.g. movzx comes out particularly bad.




回答3:


There are two distinct types of assembly language syntax - Intel and AT&T syntax. You can find a comparison of both on Wikipedia's assembly language page.

Chances are your book uses the AT&T syntax, where the source operand comes before the destination.



来源:https://stackoverflow.com/questions/2397528/mov-src-dest-or-mov-dest-src

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