All Topics  
MOV (x86 instruction)

 

   Email Print
   Bookmark   Link






 

MOV (x86 instruction)



 
 
In the x86 assembly language
X86 assembly language

x86 assembly language is the family of backwards-compatible assembly languages for the x86 class of processors, which includes Intel's Pentium series and AMD's Athlon series....
, the MOV instruction is a mnemonic
Mnemonic

A mnemonic device is a memory aid. Commonly met mnemonics are often verbal, something such as a very short poem or a special word used to help a person remember something, particularly lists, but may be visual, kinesthetic or auditory....
 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 in real mode
Real mode

Real mode, also called real address mode, is an operating mode of 80286 and later x86-compatible Central processing unit. Real mode is characterized by a 20 bit segmented memory address space , direct software access to BIOS routines and peripheral hardware, and no concept of memory protection or computer multitasking at the hardware le...
 or protected mode
Protected mode

In computing, protected mode, also called protected virtual address mode, is an operational mode of x86-compatible central processing units ....
, and an override instruction is used, the instruction may transfer 8-bit
8-bit

Eight-bit CPUs normally use an 8-bit data bus and a 16-bit address bus which means that their address space is limited to 64 KBs. This is not a "natural law", however, so there are exceptions....
s, 16-bit
16-bit

16-bit architectureThe HP 2100#Descendants and variants , introduced in 1975, was the world's first 16-bit microprocessor.Prominent 16-bit processors include the PDP-11, Intel 8086, Intel 80286 and the WDC 65C816....
s, or 32-bit
32-bit

The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295 or -2,147,483,648 through 2,147,483,647 using two's complement encoding....
s of data. Data may be copied to and from memory and registers.

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.






Discussion
Ask a question about 'MOV (x86 instruction)'
Start a new discussion about 'MOV (x86 instruction)'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In the x86 assembly language
X86 assembly language

x86 assembly language is the family of backwards-compatible assembly languages for the x86 class of processors, which includes Intel's Pentium series and AMD's Athlon series....
, the MOV instruction is a mnemonic
Mnemonic

A mnemonic device is a memory aid. Commonly met mnemonics are often verbal, something such as a very short poem or a special word used to help a person remember something, particularly lists, but may be visual, kinesthetic or auditory....
 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 in real mode
Real mode

Real mode, also called real address mode, is an operating mode of 80286 and later x86-compatible Central processing unit. Real mode is characterized by a 20 bit segmented memory address space , direct software access to BIOS routines and peripheral hardware, and no concept of memory protection or computer multitasking at the hardware le...
 or protected mode
Protected mode

In computing, protected mode, also called protected virtual address mode, is an operational mode of x86-compatible central processing units ....
, and an override instruction is used, the instruction may transfer 8-bit
8-bit

Eight-bit CPUs normally use an 8-bit data bus and a 16-bit address bus which means that their address space is limited to 64 KBs. This is not a "natural law", however, so there are exceptions....
s, 16-bit
16-bit

16-bit architectureThe HP 2100#Descendants and variants , introduced in 1975, was the world's first 16-bit microprocessor.Prominent 16-bit processors include the PDP-11, Intel 8086, Intel 80286 and the WDC 65C816....
s, or 32-bit
32-bit

The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295 or -2,147,483,648 through 2,147,483,647 using two's complement encoding....
s of data. Data may be copied to and from memory and registers.

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, Y

This operation is represented by the following pseudocode
Pseudocode

Pseudocode is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but is intended for human reading rather than machine reading....
: X := Y While MOV X, Y is equivalent to X := Y, the reverse is often not true—especially in high-level programming languages, 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
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
 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
Opcode

In computer technology, an opcode is the portion of a machine language instruction that specifies the operation to be performed. Their specification and format are laid out in the instruction set architecture of the processor in question ....
s for MOV register, [address] MOV [address], register

Also there are special MOV opcodes for accessing control register
Control register

A control register is a processor register which changes or controls the general behavior of a CPU or other digital device. Common tasks performed by control registers include interrupt control, switching the addressing mode, paging control, and coprocessor control....
s: MOV ax,CR0 MOV CR0,ax (Same for other control register
Control register

A control register is a processor register which changes or controls the general behavior of a CPU or other digital device. Common tasks performed by control registers include interrupt control, switching the addressing mode, paging control, and coprocessor control....
s, test register
Test register

Test register was a register used by the processor, usually to do a self-test. Most of these registers were undocumented, and used by specialized software....
s, and debug register
Debug register

Debug register is a register used by a processor for Computer program debugging. On the x86 architecture, these are named DR0...DR7....
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,AL will move the value of AL into EAX, padding it with zeroes. For example, if AL was 0x2F, EAX would be set to 0x0000002F.