# `rcl`

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

**Rotate left through carry flag**

Category: Shifts and rotates

Rotates the destination (first) operand left through the carry flag, treating CF as one extra bit in the rotation.

8086 and later

[Intel's reference: RCL/RCR/ROL/ROR](https://intel.github.io/SDM/instruction/RCL-RCR-ROL-ROR.html)

## Flags

| Flag | Effect |
| --- | --- |
| CF | depends on the result |
| PF | not changed |
| AF | not changed |
| ZF | not changed |
| SF | not changed |
| DF | not changed |
| OF | undefined (do not rely on it). Defined only for a count of 1. |

Reads: CF

A count of 0 leaves every flag unchanged.

## Forms

- `rcl r/m, imm8` (8, 16, 32, 64)
  - `rcl r/m8, imm8`: 186 and later
  - `rcl r/m16, imm8`: 186 and later
  - `rcl r/m32, imm8`: 386 and later
  - `rcl r/m64, imm8`
- `rcl r/m, 1` (8, 16, 32, 64)
  - `rcl r/m8, 1`
  - `rcl r/m16, 1`
  - `rcl r/m32, 1`: 386 and later
  - `rcl r/m64, 1`
- `rcl r/m, cl` (8, 16, 32, 64)
  - `rcl r/m8, cl`
  - `rcl r/m16, cl`
  - `rcl r/m32, cl`: 386 and later
  - `rcl r/m64, cl`

## Operands

- `r/m`: A general-purpose register or memory location matching the operation’s size, for example `rax` or `qword [rbp-8]`.
- `imm8`: An 8-bit immediate, `-128` to `255`. Instructions that sign-extend it to a wider operand interpret the byte as `-128` to `127`; shift counts do not use this sign extension.

## Description

The rotation ring has 9, 17, 33 or 65 bits for an 8-, 16-, 32- or 64-bit operand. For example, `rcl al, 1` moves the old high bit into CF and the old CF into bit 0. `rcr` rotates in the opposite direction. OF is defined only for a count of one.

The count comes from an immediate or `cl`. It is masked to six bits for a 64-bit operand, or five bits for smaller operands. For byte and word operands, the masked count is then reduced modulo 9 or 17. For 32- and 64-bit operands, the mask limits the count to 31 or 63; a written count of 32 or 64 respectively masks to zero.

## Example

```x86
global _start

section .text
_start:
        mov rax, 12
        mov rbx, 5
        mov rcx, 3
        mov rsi, 9

        rcl rax, 1

        mov rax, 60         ; syscall 60: exit
        xor rdi, rdi
        syscall
```
