# `loopzw`

[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/loopzw

**Loop while zero, cx as the counter**

Category: Control flow

Decrements cx by one and jumps to the short target if the counter is non-zero and ZF is 1; unavailable in 64-bit mode.

8086 and later · Not available in 64-bit mode

[Intel's reference: LOOP/LOOPcc](https://intel.github.io/SDM/instruction/LOOP-LOOPcc.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 |

Reads: ZF

## Forms

- `loopzw 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

It leaves flags unchanged. A zero initial counter wraps to its maximum value when decremented.

The w suffix selects the 16-bit counter and 16-bit address size. This form is unavailable in 64-bit mode. The suffix chooses the counter width, not the branch displacement width.

Write a target label or address. NASM calculates a signed 8-bit displacement from the end of the instruction (−128 through 127 bytes). There is no longer near encoding.
