STOS Store String (Byte or Word) Flags: not altered
STOS destination-string
Logic: (ES:DI) Accumulator
if DF = 0
DI DI + n ; n = 1 for byte, 2 for word scan
else
DI DI - n
STOS copies the value (byte or word) in AL or AX into the location
pointed to by ES:DI. DI is then incremented (if the direction flag is
cleared) or decremented (if the direction flag is set), in preparation
for storing the accumulator in the next location.
--------------------------------------------------------------------------
Operands Clocks Transfers Bytes Example
byte(word)
dest-string 11(15) 1 1 STOS WORD_ARRAY
(repeat) dest-string 9 + 10(14)/rep 1/rep 1 REP STOS BYTE_ARRAY
--------------------------------------------------------------------------
Notes: This instruction is always translated by the
assembler into either STOSB, Store String Byte, or
STOSW, Store String Word, depending upon whether
destination-string refers to a string of bytes or
words. In either case, however, you must explicitly
load the DI register with the offset of the string.
-------------------------------- Example ---------------------------------
When used in conjunction with the REP prefixes, the Store String
instructions are useful for initializing a block of memory. For
example, the following code would initialize the 100-byte memory block
at BUFFER to 0:
MOV AL,0 ;The value to initialize BUFFER to
LEA DI,BUFFER ;Starting location of BUFFER
MOV CX,100 ;Size of BUFFER
CLD ;Let's move in forward direction
REP STOS BUFFER ;Compare this line to example for STOSB
Seealso:
This page last updated on Fri Nov 30 10:49:50 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster