Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- iAPx86 - <b>rep / repne repeat string instruction flags: o d i t s z a p c</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
REP / REPNE     Repeat String Instruction            Flags: O D I T S Z A P C
                                                            (See instruction)
REP string_instruction          Repeat
REPE/REPZ string_instruction    Repeat While Equal/Zero
REPNE/REPNZ string_instruction  Repeat While Not Equal/Not Zero

        Logic   ; MOVS,STOS,LODS,INS,OUTS
                while eCX <> 0
                   execute string instruction once
                   eCX . eCX - 1
                endwhile
                --------------------------------------------------
                ; CMPS,SCAS
                while eCX <> 0
                   execute string instruction once
                   eCX . eCX - 1
                   exit iteration if ZF=0 (REPE) | if ZF=1 (REPNE)
                endwhile

    REP, REPE, and REPNE are prefixes that can be specified before any
    string instruction (CMPS, MOVS, SCAS, INS, OUTS (or LODS)). The
    prefix causes the string instruction following it to be repeated
    the number of times indicated in the count register or (for REPE
    and REPNE) until the indicated condition in the zero flag is no
    longer met.
    REP combined with MOVS or SCAS permits fast memory-to-memory move
    or scanning operations.

    If the address-size attribute is 16 bits, CX is used for the count
    register; otherwise the address-size attribute is 32 bits and ECX
    is used. If the count value is initially zero, the instruction is
    not executed and no flags are changed.


    REP is used with MOVS, STOS, INS, OUTS (or LODS); the flags are
    not used or modified by these instructions.

    REPE and REPNE are used with CMPS and SCAS which use the zero flag
    (ZF) and determine the OF,SF,ZF,AF,PF,CF flags. (The ZF flag need
    not be initialized before REPcc CMPS/SCAS.)


    The REP prefixes apply only to one instruction at a time. To
    repeat a block of instructions, use a loop construct. Any pending
    interrupts are acknowledged on each iteration of REP.


    Note
    Instructions with one of the REP prefixes, combined with a segment
    override and/or another prefix, (e.g. rep movs [byte ss:si],[byte
    es:di] ) execute incorrectly on 8086/8088 CPUs if an interrupt
    occurs before CX reaches 0. Some sources say this bug is present
    on all pre-80386 CPUs.


    Opcode      Format
    F2 ...      REPNE ...               ; Prefix
    F3 ...      REPE ...
    F3 ...      REP ...                 ; REP = REPE


    Length and timing
    Refer to REPeated instruction.

See Also: CLD STD CMPS INS LODS MOVS OUTS SCAS STOS LOOP JCXZ

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