LOOPZ
and LOOPE
Instructions
LOOPZ
(loop if zero) and LOOPE
(loop if equal) instruction permit a loop to continue while the Zero
flag is set and the unsigned value of ECX
is greater than zero. The following code is the execution logic of them:
ECX = ECX - 1 if (ECX > 0 and ZF = 1) jump to destinationThe loop destination must be within –128 to +127 bytes of the current location counter.
LOOPZ/LOOPE — LOOP If Equal (Zero) |
||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
LOOP |
LOOPZ |
LOOPE |
---|---|---|
INCLUDE Irvine32.inc .code main PROC count = 6 mov eax, 0 mov ecx, count L1: add al, cl test al, 0F0h loop L1 call WriteInt exit main ENDP END main |
INCLUDE Irvine32.inc .code main PROC count = 6 mov eax, 0 mov ecx, count L1: add al, cl test al, 0F0h loopz L1 call WriteInt exit main ENDP END main |
INCLUDE Irvine32.inc .code main PROC count = 6 mov eax, 0 mov ecx, count L1: add al, cl test al, 0F0h loope L1 call WriteInt exit main ENDP END main |
Output | Output | Output |