What is the mov instruction and what are its forms?
mov copies data from a source to a destination — the most common x86 instruction — but it cannot move directly from one memory location to another.
* mov allows every source/destination pair except memory-to-memory, which must be staged through a register. *
mov is deceptively central: most of what code does is shuffle values between registers, memory, and immediates, and mov is the workhorse for all of it.
mov $imm, reg # immediate → register
mov $imm, mem # immediate → memory
mov reg, reg # register → register
mov reg, mem # register → memory
mov mem, reg # memory → register
The one combination that's illegal: memory-to-memory in a single instruction. You must stage through a register:
mov mem, mem # NOT allowed — use a register as intermediate
Like other instructions, mov takes a size suffix (movb, movw, movl, movq).
Two behaviors worth memorizing: movl into a 32-bit register zeros the upper 32 bits of the 64-bit register, and mov with an immediate is limited to a 32-bit (sign-extended) constant — to load a full 64-bit immediate you need movabs.
Go deeper:
Felix Cloutier — MOV — the authoritative operand-form table and the memory-to-memory restriction.