
Click above to get retro games delivered to your door ever month!
X-Hacker.org- iAPx86 - <b>movs move string flags: not altered</b>
[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
MOVS Move String Flags: Not altered
MOVS source_string,destination_string
Logic [ES:eDI] . [DS:eSI]
if DF = 0
eSI . eSI + n ; n = 1 for byte, 2 for word,
eDI . eDI + n ; 4 for dword (386+)
else
eSI . eSI - n
eDI . eDI - n
endif
MOVS copies the byte, word, or doubleword at DS:eSI to the byte,
word, or doubleword at ES:eDI. After the transfer, eSI and eDI are
incremented (if the direction flag is cleared) or decremented (if
the direction flag is set), in preparation for copying the next
element of the string. If the address-size attribute of MOVS is
16 bits, the SI and DI registers will be used as source and
destination indices; if 32 bits, ESI and EDI will be used.
The source segment can be changed with a segment override, the
destination segment cannot.
Note: This instruction is always translated by the
assembler into MOVSB, Move String Byte, MOVSW,
Move String Word, or MOVSD, Move String Dword,
depending upon whether source refers to a string of
bytes, words or doublewords. In either case, you must
explicitly load the eSI and eDI registers with the
offset of the source and destination strings.
MOVSB, MOVSW, and MOVSD are synonyms for the byte,
word, and doubleword MOVS instructions that do not
require any operands. They are simpler to use but
provide no type or segment checking.
If the REP prefix modifies this instruction, the CPU moves the
value of the source string element to the value of the destination
string element. It then steps eSI and eDI in the direction
indicated by DF by the indicated size, until either the REP
condition is false or eCX counts to zero.
Example:
dataseg
src db "A string",0
dest db 9 dup (0)
codeseg
mov di,ds
mov es,di
assume ds:dgroup,es:dgroup
mov di,offset dest
mov si,offset src
mov cx,9
cld
rep movs [src],[dest] ; rep movsb
; ax register unchanged by MOVS
Opcode Format
A4 MOVS m8,m8 ; = MOVSB
A5 MOVS m16,m16 ; = MOVSW
A5 MOVS m32,m32 ; = MOVSD
Length and timing
Variations Bytes 8088 186 286 386 486 Pentium
movsb 1 18 9 5 7 7 4 NP
movsw 1 26 9 5 7 7 4 NP
movsd 1 - - - 7 7 4 NP
rep movsb 2 9+17n 8+8n 5+4n 7+4n 12+3n* 3+n NP
rep movsw 2 9+25n 8+8n 5+4n 7+4n 12+3n* 3+n NP
rep movsd 2 - - - 7+4n 12+3n* 3+n NP
* = 5 if n=0, 13 if n=1
(n = count of bytes, words or dwords)
See Also: REP CLD STD STOS MOV
Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson