cld
Clear direction flag
Clears the direction flag (DF), so string instructions step upward through memory.
8086 and later
Used in
- Arrays, strings and the string instructionsx86-64 assembly
- Length of a stringx86-64 assembly
CFPFAFZFSFDFOF –––––0–
- 0 always 0
- – not changed
Forms
cld
The Linux calling convention expects DF to be clear at every call and return, so code that sets it with std clears it again before either.
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