# `cld`

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

**Clear direction flag**

Category: System

Clears the direction flag (DF), so string instructions step upward through memory.

8086 and later

[Intel's reference: CLD](https://intel.github.io/SDM/instruction/CLD.html)

Used in: [Arrays, strings and the string instructions](https://asm-editor.specy.app/learn/courses/x86/think-in-assembly/arrays-strings-and-the-string-instructions.md) (x86-64 assembly), [Length of a string](https://asm-editor.specy.app/learn/courses/x86/examples/string-length.md) (x86-64 assembly)

## Flags

| Flag | Effect |
| --- | --- |
| CF | not changed |
| PF | not changed |
| AF | not changed |
| ZF | not changed |
| SF | not changed |
| DF | always 0 |
| OF | not changed |

## Forms

- `cld`

## Description

The Linux calling convention expects DF to be clear at every call and return, so code that sets it with [`std`](https://asm-editor.specy.app/documentation/x86/instruction/std.md) clears it again before either.

## Example

```x86
global _start

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

        cld

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