<<< LOOPNZ/LOOPNE Loop While CX/ECX > 0 and ZF = 0     Index     MOV Move (Copy) Right Operand into Left Operand >>>


LOOPZ/LOOPE Loop While CX/ECX > 0 and ZF = 1

Flags affected:

        O D I T S Z A P C  OF: Overflow flag  TF: Trap flag AF: Aux carry
        F F F F F F F F F  DF: Direction flag SF: Sign flag PF: Parity flag
            <none>         IF: Interrupt flag ZF: Zero flag CF: Carry flag

Legal forms:

        LOOPZ d8
        LOOPE d8

Examples:

        LOOPZ SenseOneShots
        LOOPE CRCGenerate

Notes:

LOOPZ and LOOPE are synonyms and generate identical opcodes. Like LOOP, they use either CX or ECX depending on the BITS setting and hence the mode. LOOPZ/LOOPE decrements CX and jumps to the location specified in the target operand if CX is not 0 and the Zero flag ZF is 1. Otherwise, execution falls through to the next instruction.

What this means is that the loop is pretty much controlled by ZF. If ZF remains 1, the loop is looped until CX is decremented to 0. But as soon as ZF is cleared to 0, the loop terminates. Think of it as "Loop While Zero Flag."

Keep in mind that LOOPZ does not itself affect ZF. Some instruction within the loop (typically one of the string instructions) must do something to affect ZF to terminate the loop before CX/ECX counts down to 0.

        r8 = AL AH BL BH CL CH DL DH        r16 = AX BX CX DX BP SP SI DI
        sr = CS DS SS ES FS GS              r32 = EAX EBX ECX EDX EBP ESP ESI EDI
        m8 = 8-bit memory data              m16 = 16-bit memory data
        m32 = 32-bit memory data            i8 = 8-bit immediate data
        i16 = 16-bit immediate data         i32 = 32-bit immediate data
        d8 = 8-bit signed displacement      d16 = 16-bit signed displacement
        d32 = 32-bit unsigned displacement


<<< LOOPNZ/LOOPNE Loop While CX/ECX > 0 and ZF = 0     Index     MOV Move (Copy) Right Operand into Left Operand >>>