# `sra`

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

**Shift right arithmetic**

Category: Shifts and rotates

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

## 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

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

- `sra (hl)` · 2 bytes · 15 cycles · Shifts (HL) right one bit position. Copies bit 0 to the carry flag and leaves bit 7 unchanged.

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

## Undocumented

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

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