x86 Assembly Language Reference Manual

Load and Move Instructions

Load Effective Address (lea)

lea{wl}		r/m[16|32], reg[16|32]
Operation

Addr(m) -> r16 Addr(m) -> r32

Truncate to 16 bits(Addr(m)) -> r16

Truncate to 16 bits(Addr(m)) -> r32

Description

The offset part of the effective address is calculated by lea and stored in the specified register. The specified register determines the operand-size attribute if the instruction. The USE attribute of the segment containing the second operand determines the address-size attribute.

Example
leal 0x33333333, %edx

Move (mov)

mov{bwl}		imm[8|16|32], r/m[8|16|32]
mov{bwl}		reg[8|16|32], r/m[8|16|32]
mov{bwl}		r/m[8|16|32], reg[8|16|32]
Operation

SRC -> DEST

Description

mov stores or loads the following special registers in or from a general purpose register.

These instructions always use 32-bit operands.

Example
movl %cr3, %ebp
 movl %db7, %ebp
 movl %ebp, %cr3
 movl %ebp, %db7
 movl %tr7, %ebp
 movl %ebp, %tr7

Move Segment Registers (movw)

movw	sreg,r/m16
movw	r/m16, sreg

Operation

r/m16 -> Sreg

Sreg -> r/m16

Description

movw copies the first operand to the second operand, including data from a descriptor. The descriptor table entry for the selector contains the data for the register. The DS and ES registers can be loaded with a null selector without causing an exception. Use of DS or ES however, causes a #GP(0), and no memory reference occurs.

All interrupts are inhibited until after the execution of the next instruction, after a movw into SS. Special actions and checks result from loading a segment register under Protected Mode.

Example
movw %CS, 5(%ebx)
 movw %(%ebx), %CS

Move Control Registers (mov)

mov{l}	creg, reg32
mov{l}	reg32, creg

Operation

SRC -> DEST

Description

This form of mov stores or loads the Control Register CR0, CR2, or CR4 to or from a general purpose register.

These instructions are always used with 32-bit operands.

Example
movl %cr3, %ebp
 movl %ebp, %cr3

Move Debug Registers (mov)

mov{l}	dreg, reg32
mov{l}	reg32, dreg
Operation

SRC -> DEST

Description

This form of mov stores or loads the Debug Register DR1, DR2, or DR3, DR6, and DR7 to or from a general purpose register.

These instructions are always used with 32-bit operands.

Example
movl %db7, %ebp
 movl %ebp, %db7

Move Test Registers (mov)

mov{l}	treg, reg32
mov{l}	reg32, treg
Operation

SRC -> DEST

Description

This form of mov stores or loads the Test Register TR6 or TR7 to or from a general purpose register.

These instructions are always used with 32-bit operands.

Example
movl %tr7, %ebp
 movl %ebp, %tr7

Move With Sign Extend (movsx)

movsx{wl}		r/m8, reg[16|32]
movsxwl		r/m16, reg32
Operation

SignExtend(SRC) -> DEST

Description

movsx reads the contents of the register or effective address as a word or byte. movsx then sign-extends the 16- or 32-bit value to the operand-size attribute of the instruction. The result is stored in the destination register by movsx.

Example
movsxbl 1(%esi), %edx
 movsxwl 5(%ebx), %edx

Move With Zero Extend (movzb)

movzb[wl]		r/m8, reg[16|32]
movzwl		r/m16, reg32
Operation

SignExtend(SRC) -> DEST

Description

movzx reads the contents of the register or effective address as a word or byte. movzx then sign-extends the 16- or 32-bit value to the operand-size attribute of the instruction. The result is stored in the destination register by movzx.