x86 Assembly Language Reference Manual

Move Data from String to String (movs)

movs{bwl}
movs{bwl} m[8|16|32], reg[16|32] 
Operation

move {bwl} [(E)SI] -> ES: (E)DI]

move {bwl} DS: [(E)SI] -> ES: [(E)DI]

Description

Copies the byte, word, or long in [(E)SI] to the byte, word, or long in ES:[(E)DI}. Before executing the move instruction, load the index values into the SI source- and DI destination-index registers.

The destination operand must be addressable from the ES register; it cannot span segments. A source operand, however, can span segments; the default is DS.

After the data is moved, both the source- and destination-index registers are automatically incremented or decremented as determined by the value of the direction flag (DF). The index registers are incremented if DF = 0 (DF cleared by a cld instruction); they are decremented if DF = 1 (DF set by a std instruction). The increment/decrement count is 1 for a byte move, 2 for a word, and 4 for a long.

For a block move of CX bytes or words, precede a movs instruction with a rep prefix.

Example

Copy the 8-bit byte from the DS:[(E)SI] to the ES:[(E)DI] register.

movsb