views:

215

answers:

3

Can anyone please explain me the difference between the assembly instructions LOOP, LOOPE and LOOPNE.

Thanks.

+4  A: 

Time for a Google Books Reference

EDIT: Synopsis from link: LOOPE and LOOPNE are essentially LOOP instructions with one additional check. LOOPE loops "while zero flag," meaning it will loop as long as zero flag ZF is one and the increment is not reached, and LOOPNE loops "while not zero flag," meaning it continues the loop as long as ZF is zero and the increment is not reached. Keep in mind that neither of these instructions inherently affect the status of ZF.

Matthew Jones
I believe that it is best to not only provide a link, but quote relevant material from the source, should the link ever become invalid.
Thomas Owens
+6  A: 

LOOP decrements ecx and checks if ecx is not zero, if that condition is met it jumps at specified label, otherwise falls through.

LOOPE decrements ecx and checks that ecx is not zero and ZF is set - if these conditions are met, it jumps at label, otherwise falls through.

LOOPNE is same as LOOPE except that it requires ZF to be not set (i.e be zero) to do the jump.

sharptooth
Also not asked I'd like to point out that all LOOP instructions are much slower than the DEC ECX / JNZ counterpart. This is intended as LOOP should nowadays only be used for delay calibration loops used for hardware-drivers and the like.
Nils Pipenbrinck
A: 

Have you tried looking it up in an instruction set reference, for example in this one by Intel?

starblue