def LOOP(cpu, dest):
counter_name = {<NUM_LIT:16>: '<STR_LIT>', <NUM_LIT:32>: '<STR_LIT>', <NUM_LIT:64>: '<STR_LIT>'}[cpu.address_bit_size]<EOL>counter = cpu.write_register(counter_name, cpu.read_register(counter_name) - <NUM_LIT:1>)<EOL>cpu.PC = Operators.ITEBV(cpu.address_bit_size, counter == <NUM_LIT:0>, (cpu.PC + dest.read()) & ((<NUM_LIT:1> << dest.size) - <NUM_LIT:1>), cpu.PC + cpu.instruction.size)<EOL>
Loops according to ECX counter.

Performs a loop operation using the ECX or CX register as a counter.
Each time the LOOP instruction is executed, the count register is decremented,
then checked for 0. If the count is 0, the loop is terminated and program
execution continues with the instruction following the LOOP instruction.
If the count is not zero, a near jump is performed to the destination
(target) operand, which is presumably the instruction at the beginning
of the loop. If the address-size attribute is 32 bits, the ECX register
is used as the count register; otherwise the CX register is used::

        IF address_bit_size  =  32
        THEN
            Count is ECX;
        ELSE (* address_bit_size  =  16 *)
            Count is CX;
        FI;
        Count  =  Count - 1;

        IF (Count  0)  =  1
        THEN
            EIP  =  EIP + SignExtend(DEST);
            IF OperandSize  =  16
            THEN
                EIP  =  EIP AND 0000FFFFH;
            FI;
        ELSE
            Terminate loop and continue program execution at EIP;
        FI;

:param cpu: current CPU.
:param dest: destination operand.