Moving Data Between Registers

We can move data from one register to another, so long as they are of the same size.

For example, to move the contents of DH into CL we write:


Note that the source register goes on the right and the destination register goes on the left.


Movement to and From Memory

We can use the same instruction to move data from memory to registers and vice versa. Note that we cannot move data from memory to memory with the MOV instruction.

If we want to move the data at a byte memory location called myvar into AH say, we would write

MOV AH,[myvar]

Note that the square brackets tell the machine to move the actual data into AH, not the address of the data.

The assembler requires that the source and destination are of matching sizes. For example, you can't move data from a variable which was declared as a byte of data, into a 16 or 32 bit register.

However, this functionality can be easily overridden. Suppose we have a byte variable called myvar1 and we wish to move the word of data starting at that location, into the AX register. We simply type

MOV word AX,[myvar1]

Of course this will take both the byte of data stored in the variable myvar1 and the byte that just happens to follow it in memory, and place the two bytes as a single word into AX.

The similar overrides for moving a byte and a double word of data are denoted byte and dword respectively.

Obviously if we want to move data from a register into memory, we just put the operands in the reverse order, e.g.

MOV [myvar1],CH