Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Assembly Language - <b>lodsw load string word flags: not altered</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
LODSW            Load String Word                    Flags: not altered

LODSW

          Logic:    AX . (DS:SI)
                    if DF = 0
                        SI . SI + 2
                    else
                        SI . SI - 2

    LODSW transfers the word pointed to by DS:SI into AX and increments or
    decrements SI (depending on the state of the Direction Flag) to point
    to the next word of the string.

  --------------------------------------------------------------------------
   Operands                  Clocks   Transfers  Bytes   Example
      -                        16         -        1     LODSW
   (repeat)                 9+17/rep    1/rep      1     REP LODSW
  --------------------------------------------------------------------------

       Note:          Although it is legal to repeat this instruction, it
                      is almost never done since doing so would
                      continually overwrite the value in AL.

  -------------------------------- Example ---------------------------------

    The following example sends the eight bytes at INIT_PORT to port 250.
    (Don't try this on your machine, unless you know what's hanging off
    port 250.)

  INIT_PORT:
          DB      '$CMD0000'      ;The string we want to send
          .
          .
          CLD                     ;Move forward through string at INIT_PORT
          LEA     SI, INIT_PORT   ;SI gets starting address of string
          MOV     CX, 4           ;Moving 4 words (8 bytes)
  AGAIN:  LODSW                   ;Load a word into AX...
          OUT     250,AX          ;   ...and output it to the port.
          LOOP    AGAIN

See Also: LODS LODSB CMPS MOVS SCAS STOS REP CLD STD

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