Opcode Instruction Clocks Description A4 MOVS m8,m8 7 Move byte [(E)SI] to ES:[(E)DI] A5 MOVS m16,m16 7 Move word [(E)SI] to ES:[(E)DI] A5 MOVS m32,m32 7 Move dword [(E)SI] to ES:[(E)DI] A4 MOVSB 7 Move byte DS:[(E)SI] to ES:[(E)DI] A5 MOVSW 7 Move word DS:[(E)SI] to ES:[(E)DI] A5 MOVSD 7 Move dword DS:[(E)SI] to ES:[(E)DI]
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; FI; IF byte type of instruction THEN [destination-index] := [source-index]; (* byte assignment *) IF DF = 0 THEN IncDec := 1 ELSE IncDec := -1; FI; ELSE IF OperandSize = 16 THEN [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; FI; FI; source-index := source-index + IncDec; destination-index := destination-index + IncDec;
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.
up:
Chapter 17 -- 80386 Instruction Set
prev: MOV Move to/from Special Registers
next: MOVSX Move with Sign-Extend