80386 Programmer's Reference Manual -- Opcode MOVS

MOVS/MOVSB/MOVSW/MOVSD -- Move Data from String to String

OpcodeInstructionClocks DescriptionExample
A4movsb 7 Move byte DS:[(E)SI] to ES:[(E)DI]movsb
A5movsw 7 Move word DS:[(E)SI] to ES:[(E)DI]movsw
A5movsl 7 Move dword DS:[(E)SI] to ES:[(E)DI]movsl


IF (instruction = MOVSD) OR (instruction has doubleword operands)
THEN OperandSize := 32;
ELSE OperandSize := 16;
IF AddressSize = 16
THEN use SI for source-index and DI for destination-index;
ELSE (* AddressSize = 32 *)
   use ESI for source-index and EDI for destination-index;
IF byte type of instruction
   [destination-index] := [source-index]; (* byte assignment *)
   IF DF = 0 THEN IncDec := 1 ELSE IncDec := -1; FI;
   IF OperandSize = 16
      [destination-index] := [source-index]; (* word assignment *)
      IF DF = 0 THEN IncDec := 2 ELSE IncDec := -2; FI;
   ELSE (* OperandSize = 32 *)
      [destination-index] := [source-index]; (* doubleword assignment *)
      IF DF = 0 THEN IncDec := 4 ELSE IncDec := -4; FI;
source-index := source-index + IncDec;
destination-index := destination-index + IncDec;


MOVS copies the byte or word at [(E)SI] to the byte or word at ES:[(E)DI]. The destination operand must be addressable from the ES register; no segment override is possible for the destination. A segment override can be used for the source operand; the default is DS.

The addresses of the source and destination are determined solely by the contents of (E)SI and (E)DI. Load the correct index values into (E)SI and (E)DI before executing the MOVS instruction. MOVSB, MOVSW, and MOVSD are synonyms for the byte, word, and doubleword MOVS instructions.

After the data is moved, both (E)SI and (E)DI are advanced automatically. If the direction flag is 0 (CLD was executed), the registers are incremented; if the direction flag is 1 (STD was executed), the registers are decremented. The registers are incremented or decremented by 1 if a byte was moved, 2 if a word was moved, or 4 if a doubleword was moved.

MOVS can be preceded by the REP prefix for block movement of CX bytes or words. Refer to the REP instruction for details of this operation.

Flags Affected


Protected Mode Exceptions

#GP(0) if the result 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]