Description:
mov
copies values of bits from source argument to destination argument.
Common source/destination are registers, usually the fastest way to manipulate values with[in] CPU.
Another important group of source_of/destination_for values is computer memory.
Finally some immediate values may be part of the mov
instruction encoding itself, saving time of separate memory access by reading the value together with instruction.
On x86 CPU in 32 and 64 bit mode there are rich possibilities to combine these, especially various memory addressing modes. Generally memory-to-memory copying is out limit (except specialized instructions like MOVSB
), and such manipulation requires intermediate storage of values into register[s] first.
Step 1: Set up your project to use MASM, see Executing x86 assembly in Visual Studio 2015
Step 2: Type in this:
.386
.model small
.code
public main
main proc
mov ecx, 16 ; Move immediate value 16 into ecx
mov eax, ecx ; Copy value of ecx into eax
ret ; return back to caller
; function return value is in eax (16)
main endp
end main
Step 3: Compile and debug.
The program should return value 16
.