MOVSW/MOVSB : Move String Word or String Byte: Imagine a string of bytes, stored in a set of consecutive memory locations is to be moved to another set of the destination locations. Starting byte of the source string is located in the memory location whose address can be computed by using DS (data segment) and SI (source index) contents. Starting address of the destination locations where this string has to be relocated is given by ES (extra segment) and Dl (destination index) contents. Starting address of the source string is 10H*DS+[SI], whereas the starting address of the destination string is 10H*ES+[DI]. The MOVSB/MOVSW instruction therefore, moves a string of bytes/ words pointed to by DS: SI pair (source) to the memory location pointed to by ES: Dl pair (destination). The REP instruction prefix is utilized with MOVS instruction to repeat it by a value given in the register counter (CX). The length of word string or byte string ought to be stored in register CX register. Flags are remaining unaffected by this instruction.
After the MOVS instruction is executed, the index registers are automatically updated and register CX is decremented. The decrementing or incrementing of the pointers, for example DI and Sl depend on the direction flag DF. If flag DF is 0, the index registers are incremented, or else, they are decremented, in all casa of the string manipulation instructions. Following string of instructions explain the execution of the MOVS instruction.