# `rrc`

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

**Rotate right circular**

Category: Shifts and rotates

Rotates a register or memory byte right one bit, copying bit 0 to C and to bit 7.

## Flags

| Flag | Effect |
| --- | --- |
| S | set from the result |
| Z | set from the result |
| H | always 0 |
| P/V | holds the parity of the result |
| N | always 0 |
| C | set from the result |

## Forms

- `rrc r` · 2 bytes · 8 cycles · The contents of `r` are rotated right one bit position. The contents of bit 0 are copied to the carry flag and bit 7.
  - `rrc b`
  - `rrc c`
  - `rrc d`
  - `rrc e`
  - `rrc h`
  - `rrc l`
  - `rrc a`

- `rrc (hl)` · 2 bytes · 15 cycles · The contents of (HL) are rotated right one bit position. The contents of bit 0 are copied to the carry flag and bit 7.

- `rrc (ix+dd)` · 4 bytes · 23 cycles · The contents of the memory location pointed to by IX plus `dd` are rotated right one bit position. The contents of bit 0 are copied to the carry flag and bit 7.
  - `rrc (ix+dd)`
  - `rrc (iy+dd)`

## Undocumented

Left out of Zilog's manual, but the Z80 runs them, and so does this emulator.

- `rrc (ix+dd), r` · 4 bytes · 23 cycles · The contents of the memory location pointed to by IX plus `dd` are rotated right one bit position. The contents of bit 0 are copied to the carry flag and bit 7. The result is then stored in `r`.
  - `rrc (ix+dd), b`
  - `rrc (ix+dd), c`
  - `rrc (ix+dd), d`
  - `rrc (ix+dd), e`
  - `rrc (ix+dd), h`
  - `rrc (ix+dd), l`
  - `rrc (ix+dd), a`
  - `rrc (iy+dd), b`
  - `rrc (iy+dd), c`
  - `rrc (iy+dd), d`
  - `rrc (iy+dd), e`
  - `rrc (iy+dd), h`
  - `rrc (iy+dd), l`
  - `rrc (iy+dd), a`

## Operands

- `r`: An 8-bit register: `a`, `b`, `c`, `d`, `e`, `h` or `l`.
- [`(hl)`](https://asm-editor.specy.app/documentation/z80/registers/operand-hl.md): The byte in memory at the address stored in `hl`.
- [`(ix+dd)`](https://asm-editor.specy.app/documentation/z80/registers/operand-ix-dd.md): The byte in memory at `ix + dd`, where `dd` is a signed displacement from `-128` to `127`, for example `(ix+5)` or `(ix-3)`. `(iy+dd)` works the same way.

## Example

```z80
        .org 0x8000
        ld b, 3
        rrc b
        halt
```
