loopCC - loop if CC

rip = dest if rcx is not 0 or CC is true

There are 2 versions of loopCC: loope and loopne. Both instructions decrement rcx and the loop will end if rcs == 0; In addition an operation within the loop can affect the zero flag and if ZF matches the condition control will transfer to the destination. The only choice is for the destination to be an 8 bit rip-relative offset. For this reason it can only be used for moderate sized loops.

mov ecx, 100 ; set rcx to 100 loop_top: ... cmp rax, rdx loope loop_top ; loop executes 100 times ; or until rax is not equal to rdx

And now an example with loopne

        mov     ecx, 100            ; set rcx to 100
loop_top:
        ...
        cmp     al, 0x0a           ; compare against new-line
        loopne  loop_top           ; loop executes 100 times
                                   ; or until al equals '\n'

flags: none