# `rr`

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

**Rotate right through carry**

Category: Shifts and rotates

Rotates a register or memory byte right one bit, moving C into bit 7 and bit 0 into C.

Used in: [Flappy ASM](https://asm-editor.specy.app/learn/courses/z80/examples/flappy-asm.md) (Z80 assembly)

## Flags

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

## Forms

- `rr r` · 2 bytes · 8 cycles · Rotates `r` right one bit position. Copies bit 0 to the carry flag and the previous carry flag to bit 7.
  - `rr b`
  - `rr c`
  - `rr d`
  - `rr e`
  - `rr h`
  - `rr l`
  - `rr a`

- `rr (hl)` · 2 bytes · 15 cycles · Rotates (HL) right one bit position. Copies bit 0 to the carry flag and the previous carry flag to bit 7.

- `rr (ix+dd)` · 4 bytes · 23 cycles · Rotates the memory location pointed to by IX plus `dd` right one bit position. Copies bit 0 to the carry flag and the previous carry flag to bit 7.
  - `rr (ix+dd)`
  - `rr (iy+dd)`

## Undocumented

Zilog’s manual does not list these forms, but the Z80 runs them.

- `rr (ix+dd), r` · 4 bytes · 23 cycles · Rotates the memory location pointed to by IX plus `dd` right one bit position. Copies bit 0 to the carry flag and the previous carry flag to bit 7. Also stores the result in `r`.
  - `rr (ix+dd), b`
  - `rr (ix+dd), c`
  - `rr (ix+dd), d`
  - `rr (ix+dd), e`
  - `rr (ix+dd), h`
  - `rr (ix+dd), l`
  - `rr (ix+dd), a`
  - `rr (iy+dd), b`
  - `rr (iy+dd), c`
  - `rr (iy+dd), d`
  - `rr (iy+dd), e`
  - `rr (iy+dd), h`
  - `rr (iy+dd), l`
  - `rr (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
        rr b
        halt
```
