# `cpl`

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

Web page: https://asm-editor.specy.app/documentation/z80/instruction/cpl

**Complement A**

Category: Logic

Inverts every bit of A, giving its one's complement.

1 byte · 4 cycles

Used in: [8-bit and 16-bit arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/z80/think-in-assembly/arithmetic-logic-and-bits.md) (Z80 assembly)

## Flags

| Flag | Effect |
| --- | --- |
| S | not changed |
| Z | not changed |
| H | always 1 |
| P/V | not changed |
| N | always 1 |
| C | not changed |

## Forms

- `cpl` · Inverts every bit of A (one's complement).

## Example

```z80
        .org 0x8000
        ld a, 5
        cpl
        halt
```
