开发者

About mov in assembly

开发者 https://www.devze.com 2023-01-16 05:22 出处:网络
move the contents of the regist开发者_开发知识库er bx into the register ax MOV ax, bx Why is the syntax so strange?

move the contents of the regist开发者_开发知识库er bx into the register ax

MOV ax, bx

Why is the syntax so strange?

Mov ax, (to) bx actually means move contents of bx to ax ,is there any historical reason to define it this way?


Consider a code

x = 5

This probably assigns value 5 to x. Would you like 5 = x?

Similarly, You should not try to compare the language English with coding. Thats what historically also happened. English might say move this to that. But computer architects like that to this.

So basically the process of :

X := Y

could be better summarized as :

MOV X, Y


MOV ax, bx

This means, ax = bx (move bx to ax, more exactly, copy bx to ax). In this Assembly syntax first operand is destination - this is usual case, for example, in C functions:

strcpy(dest, source);

In AT&T Assembler first operand is source. Generally, it looks strange and AT&T Assembler users make interesting bugs because of this.


Excerpt from wikipedia

Syntax: x86 assembly language has two main syntax branches: Intel syntax, originally used for documentation of the x86 platform, and AT&T syntax. Intel syntax is dominant in the MS-DOS and Windows world. In the Unix/Linux world, both are used because GCC only supported AT&T-syntax in former times.

0

精彩评论

暂无评论...
验证码 换一张
取 消