The JCXZ instruction

Short jump if the CX register is 0.

The JCXZ instruction format

InstructionDescription
JCXZ rel8Short jump if the CX register is 0.

The instruction checks the value of the cx register. If the cx register is 0, a jump to the specified label is performed; otherwise the program continues with the next instruction. It is useful for skipping loops that must not be executed.

Usage example

In this example the CX register is 0, so the inc ax instruction is skipped and the program jumps to the Skip label.

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

code segment public        ; Start of the code segment
    assume cs:code

    main proc              ; Start of the main procedure
        xor     cx, cx     ; Clear the cx register
        jcxz    Skip       ; If CX=0, jump to the Skip label

        inc     ax         ; This instruction will be skipped

    Skip:
        mov     ax, 4C00h  ; Copy the process termination function number into ah and the value into al
        int     21h        ; Call the interrupt
    main endp              ; End of the main procedure

code ends                  ; End of the code segment
end main                   ; End of file. The main procedure is the entry point

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".

Processor status flags

CF
No
PF
No
AF
No
ZF
No
SF
No
TF
No
IF
No
DF
No
OF
No