Repeat while Not Equal                            

86/88

Y

186

Y

286

Y

386

Y

486

Y

REPNE string_instruction

Ovfl

N

Dir

N

Int

N

Trap

N

Sign

N

Zero

N

Aux

N

Prty

N

Carry

N

    REPNE is a prefix that may be specified before any string instruction
    (CMPS, LODS, MOVS, SCAS, and STOS). REPNE causes the string
    instruction following it to be repeated, as long as CX does not equal
    0; CX is decremented after each execution of the string instruction.
    (For CMPS and SCAS, REP will also terminate the loop if the Zero Flag
    is set after the string instruction executes. Compare this to REP,
    which will terminate if the Zero Flag is clear.)

       Notes:         If CX is initially 0, the REPeated instruction is
                      skipped entirely.

                      The test for CX equal to 0 is performed before the
                      instruction is executed.  The test for the Zero Flag
                      set (done only for CMPS and SCAS) is performed after
                      the instruction is executed.

                      REPNE and REPNZ are synonyms for the same
                      instruction.

                      You do not need to initialize ZF before using
                      repeated string instructions.

                      A repeated instruction that is interrupted between
                      repeats will correctly resume processing upon return
                      from the interrupt. However, if other prefixes are
                      used on a single instruction (for example, segment
                      override or LOCK) in addition to the REP, all
                      prefixes except the one that immediately preceded
                      the string instruction will be lost. Therefore, if
                      you must use more than one prefix on a single
                      instruction, you should disable interrupts before
                      the instruction, and enable them afterwards. Note
                      that even this precaution will not prevent a non-
                      maskable interrupt, and that lengthy string
                      operations may cause large delays in interrupt
                      processing.

------------------------------------ Timing ----------------------------------

OpCode          Instruction             386     286     86
F2 A6           REPNE CMPS m8, m8       5+9*N   5+9*N   9+22*N
F2 A7           REPNE CMPS m16, m16     5+9*N   5+9*N   9+22*N
F2 A7           REPNE CMPS m32, m32     5+9*N
F2 AE           REPNE SCAS m8           5+8*N   5+8*N   9+15*N
F2 AF           REPNE SCAS m16          5+8*N   5+8*N   9+15*N
F2 AF           REPNE SCAS m32          5+8*N

------------------------------------ Logic -----------------------------------

        while CX <> 0                   ; for MOVS, LODS, STOS
                execute string instruction
                CX = CX - 1

        while CX <> 0                   ; for CMPS, SCAS
                execute string instruction
                CX = CX - 1
                if ZF = 0 terminate

See Also REP MOVS STOS CMPS SCAS LODS CLD STD


Copyright © 1985 to 2022 Beta Systems                            Last modified: Wednesday, January 05, 2022 .