# `jrcxz`

[x86-64 Documentation](https://asm-editor.specy.app/documentation/x86.md) › [Instructions](https://asm-editor.specy.app/documentation/x86/instruction.md)

Web page: https://asm-editor.specy.app/documentation/x86/instruction/jrcxz

**Jump if rcx register is 0**

Category: Control flow

Jumps when rcx is zero, using an 8-bit displacement from the end of the instruction.

x86-64 and later

[Intel's reference: Jcc](https://intel.github.io/SDM/instruction/Jcc.html)

## Flags

| Flag | Effect |
| --- | --- |
| CF | not changed |
| PF | not changed |
| AF | not changed |
| ZF | not changed |
| SF | not changed |
| DF | not changed |
| OF | not changed |

## Forms

- `jrcxz imm8`

## Operands

- `imm8`: A branch target, written as a label or address. NASM calculates the displacement from the end of the instruction. The displacement must fit a signed byte, `-128` to `127`.

## Description

`jrcxz` tests `rcx`; `jecxz` tests `ecx` and uses the 32-bit address size in 64-bit mode. `jcxz target` tests `cx` and is unavailable in 64-bit mode because 16-bit addressing is unavailable. NASM also accepts `jcxz target, ecx` and `jcxz target, rcx` as explicit-counter aliases for `jecxz` and `jrcxz`.

The operand is a target label or address. NASM encodes a signed 8-bit displacement from the end of the instruction, reaching −128 through 127 bytes. There is no longer near encoding for these instructions.

## Example

```x86
global _start

section .text
_start:
        mov rcx, 2
        jrcxz zero          ; jumps only when rcx is zero, without reading the flags
        mov rax, 1          ; runs, because rcx is 2
zero:

        mov rax, 60         ; syscall 60: exit
        xor rdi, rdi
        syscall
```
