- MOV (x86 instruction)
In the
x86 assembly language , the MOV instruction is amnemonic for the copying of data from one location to another. The x86 assembly language actually contains a number of different opcodes that perform a move. Depending on whether the processor is inreal mode orprotected mode , and an override instruction is used, the instruction may transfer8-bit s,16-bit s, or32-bit s of data. Data may be copied to and from memory and registers. [cite web |url=http://developer.intel.com/design/pentiumii/manuals/243191.htm|title=Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual|accessdate=2007-07-13]One has to notice that using the mnemonic "move" for this operation may be seen as a misnomer, as the physical concept of "moving an object" from A to B (with place A now being empty) is changed to the concept of "making a copy" of the object at A to B (and possibly overwriting what was placed at B before).The following is an example of
Intel syntax . The example copies the value in register Y into register X: MOV X, YThis operation is represented by the following
pseudocode : X := YWhileMOV X, Y
is equivalent toX := Y
, the reverse is often not true—especially in high-level programming languages such as Python,X := Y
will translate into more complex assembly language.In AT&T assembler syntax, the above operation would be accomplished as follows: MOVB $Y, X
Either X or Y can include addressing information.
The arguments for the MOV commands can be either a register, segment register or a memory address.since the command is executed in a single CPU work cycle, not all combinations of arguments are possible.possible combinations:
move the content of the register bx into the register ax MOV ax, bx
move the content of the register ax into the memory block with the specified address MOV [address] , ax
A combination which is not possible, is a move from memory to memory, for example : MOV [address1] , [address2]
to achieve this, another MOV must be used: MOV ax, [address2] MOV [address1] , ax
Usually, there is one set of
opcode s for MOV register, [address] MOV [address] , registerAlso there are special MOV opcodes for accessing
control register s: MOV ax,CR0 MOV CR0,ax(Same for othercontrol register s,test register s, anddebug register s.)If you want to move different sizes of data, consider using
movzx .Example movzx syntax: MOVZX EAX,BH(The above code moves the higher byte of the 16-bit register BX into the 32-bit register EAX.)An example of what movzx does: MOVZX EAX,ALwill move the value of AL into EAX, padding it with zeroes.For example, if AL was 0x2F, EAX would be set to 0x0000002F.References
Wikimedia Foundation. 2010.