AngoLinux

80386 Programmer's Reference Manual -- Opcode MOV


MOV -- Move Data

OpcodeInstructionClocks DescriptionExample
88 /rmovb r8,r/m82/2 Move byte register to r/m bytemovb %bh,%dl
movb %bh,(%ebx,1)
movb %bh,m8(%ebx,1)
movb %bh,m8(%ebx,%ebp,1)
89 /rmovw r16,r/m162/2 Move word register to r/m wordmovw %bx,%cx
movw %bx,(%ebx,1)
movw %bx,(%ebx,2)
movw %bx,(%ebx,%ebp,1)
89 /rmovl r32,r/m322/2 Move dword register to r/m dwordmovl %ebx,%ecx
movl %ebx,(%ebx,2)
movl %ebx,(%ebx,4)
movl %ebx,(%ebx,%ebp,1)
8A /rmovb r/m8,r82/4 Move r/m byte to byte registermovb %dl,%bh
movb (%ebx,1),%bh
movb m8(%ebx,1),%bh
movb m8(%ebx,%ebp,1),%bh
8B /rmovw r/m16,r162/4 Move r/m word to word registermovw %cx,%bx
movw (%ebx,1),%bx
movw (%ebx,2),%bx
movw (%ebx,%ebp,1),%bx
8B /rmovl r/m32,r322/4 Move r/m dword to dword registermovl %ecx,%ebx
movl (%ebx,2),%ebx
movl (%ebx,4),%ebx
movl (%ebx,%ebp,1),%ebx
8C /rmovw sreg,r/m162/2 Move segment register to r/m wordmovw %es,%cx
movw %es,(%ebx,1)
movw %es,(%ebx,2)
movw %es,(%ebx,%ebp,1)
8D /rmovw r/m16,sreg2/5,pm=18/19 Move r/m word to segment registermovw %cx,%es
movw (%ebx,1),%es
movw (%ebx,2),%es
movw (%ebx,%ebp,1),%es
A0movb moffs8,al4 Move byte at (seg:offset) to ALmovb farmem8,%al
A1movw moffs16,ax4 Move word at (seg:offset) to AXmovw farmem16,%ax
A1movl moffs32,eax4 Move dword at (seg:offset) to EAXmovl farmem32,%eax
A2movb al,moffs82 Move AL to (seg:offset)movb %al,farmem8
A3movw ax,moffs162 Move AX to (seg:offset)movw %ax,farmem16
A3movl eax,moffs322 Move EAX to (seg:offset)movl %eax,farmem32
B0 + rbmovb imm8,reg82 Move immediate byte to registermovb $0x7f,%ch
B8 + rwmovw imm16,reg162 Move immediate word to registermovw $0x7fff,%cx
B8 + rdmovl imm32,reg322 Move immediate dword to registermovl $0x7fffffff,%ecx
C6movb imm8,r/m82/2 Move immediate byte to r/m bytemovb $0x7f,%dl
movb $0x7f,(%ebx,1)
movb $0x7f,m8(%ebx,1)
movb $0x7f,m8(%ebx,%ebp,1)
C7movw imm16,r/m162/2 Move immediate word to r/m wordmovw $0x7fff,%cx
movw $0x7fff,(%ebx,1)
movw $0x7fff,(%ebx,2)
movw $0x7fff,(%ebx,%ebp,1)
C7movl imm32,r/m322/2 Move immediate dword to r/m dwordmovl $0x7fffffff,%ecx
movl $0x7fffffff,(%ebx,2)
movl $0x7fffffff,(%ebx,4)
movl $0x7fffffff,(%ebx,%ebp,1)

Notes

moffs8, moffs16, and moffs32 all consist of a simple offset relative to the segment base. The 8, 16, and 32 refer to the size of the data. The address-size attribute of the instruction determines the size of the offset, either 16 or 32 bits.

Operation




DEST := SRC;

Description

MOV copies the second operand to the first operand.

If the destination operand is a segment register (DS, ES, SS, etc.), then data from a descriptor is also loaded into the register. The data for the register is obtained from the descriptor table entry for the selector given. A null selector (values 0000-0003) can be loaded into DS and ES registers without causing an exception; however, use of DS or ES causes a #GP(0), and no memory reference occurs.

A MOV into SS inhibits all interrupts until after the execution of the next instruction (which is presumably a MOV into eSP).

Loading a segment register under 80386 Protected Mode results in special checks and actions, as described in the following listing:




IF SS is loaded;
THEN
   IF selector is null THEN #GP(0);
FI;
   Selector index must be within its descriptor table limits else
      #GP(selector);
   Selector's RPL must equal CPL else #GP(selector);
AR byte must indicate a writable data segment else #GP(selector);
   DPL in the AR byte must equal CPL else #GP(selector);
   Segment must be marked present else #SS(selector);
   Load SS with selector;
   Load SS with descriptor.
FI;
IF DS, ES, FS or GS is loaded with non-null selector;
THEN
   Selector index must be within its descriptor table limits
      else #GP(selector);
   AR byte must indicate data or readable code segment else
      #GP(selector);
   IF data or nonconforming code segment
   THEN both the RPL and the CPL must be less than or equal to DPL in
      AR byte;
   ELSE #GP(selector);
   FI;
   Segment must be marked present else #NP(selector);
   Load segment register with selector;
   Load segment register with descriptor;
FI;
IF DS, ES, FS or GS is loaded with a null selector;
THEN
   Load segment register with selector;
   Clear descriptor valid bit;
FI;

Flags Affected

None

Protected Mode Exceptions

#GP, #SS, and #NP if a segment register is being loaded; otherwise, #GP(0) if the destination is in a nonwritable segment; #GP(0) for an illegal memory operand effective address in the CS, DS, ES, FS, or GS segments; #SS(0) for an illegal address in the SS segment; #PF(fault-code) for a page fault

Real Address Mode Exceptions

Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to 0FFFFH

Virtual 8086 Mode Exceptions

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault


[Home Page dell'ITIS "Fermi"] [80386 Programmer's Reference Manual Index] [Previous] [Next]