A.5.142 LOOP, LOOPE, LOOPZ, LOOPNE, LOOPNZ: Loop with Counter
LOOP imm ; E2 rb [8086]
LOOP imm,CX ; a16 E2 rb [8086]
LOOP imm,ECX ; a32 E2 rb [386]
LOOPE imm ; E1 rb [8086]
LOOPE imm,CX ; a16 E1 rb [8086]
LOOPE imm,ECX ; a32 E1 rb [386]
LOOPZ imm ; E1 rb [8086]
LOOPZ imm,CX ; a16 E1 rb [8086]
LOOPZ imm,ECX ; a32 E1 rb [386]
LOOPNE imm ; E0 rb [8086]
LOOPNE imm,CX ; a16 E0 rb [8086]
LOOPNE imm,ECX ; a32 E0 rb [386]
LOOPNZ imm ; E0 rb [8086]
LOOPNZ imm,CX ; a16 E0 rb [8086]
LOOPNZ imm,ECX ; a32 E0 rb [386]
LOOP decrements its counter register (either CX or ECX - if one is not
specified explicitly, the BITS setting dictates which is used) by one,
and if the counter does not become zero as a result of this operation,
it jumps to the given label. The jump has a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition that it only
jumps if the counter is nonzero _and_ the zero flag is set. Similarly,
LOOPNE (and LOOPNZ) jumps only if the counter is nonzero and the zero
flag is clear.