loop

8086 and later

Loop with Counter

loop imm8 {near|short} | loop imm8 {near|short}, cx | loop imm8 {near|short}, ecx | loop imm8 {near|short}, rcx

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.

Loading...

Forms

Every form of loop the assembler accepts, from NASM's own instruction table. The second column is the processor that introduced the form; a badge marks a form that needs an extension, that is lockable, or that long mode dropped.

FormSinceNotes
loop imm8 {near|short}8086
loop imm8 {near|short}, cx8086nolong
loop imm8 {near|short}, ecx386
loop imm8 {near|short}, rcxx86-64long