The direction flag is a
flag
A flag is a piece of fabric (most often rectangular or quadrilateral) with a distinctive design and colours. It is used as a symbol, a signalling device, or for decoration. The term ''flag'' is also used to refer to the graphic design empl ...
that controls the ''left-to-right'' or ''right-to-left'' direction of
string
String or strings may refer to:
*String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects
Arts, entertainment, and media Films
* ''Strings'' (1991 film), a Canadian anim ...
processing, stored in the
FLAGS register on all
x86-compatible
CPU
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, and ...
s.
Direction Flag
at MSDN It is bit number 10.
This flag is used to determine the direction ('forward' or 'backward') in which several bytes of data will be copied from one place in the memory, to another. The direction is important mainly when the original data position in memory and the target data position overlap.
* If it is set to 0 (using the clear-direction-flag instruction CLD
) — it means that string is processed beginning from lowest to highest address; such instructions mode is called ''auto-incrementing'' mode. Both the source index
x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel based on the Intel 8086 microprocessor and its 8088 variant. The 8086 was introd ...
and destination index
x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel based on the Intel 8086 microprocessor and its 8088 variant. The 8086 was introd ...
(like MOVS
) will increase them;
* In case it is set to 1 (using the set-direction-flag instruction STD
) — the string is processed from highest to lowest address. This is called ''auto-decrementing'' mode.
References
{{X86 assembly topics
X86 architecture