Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TASM 2.x / MASM 6.x Assembly Language - <b>stos store string (byte or word) flags: not altered</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
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

See Also: STOSB STOSW CMPS LODS MOVS SCAS REP CLD STD

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson