The direction flag is a
flag
A flag is a piece of textile, fabric (most often rectangular) with distinctive colours and design. It is used as a symbol, a signalling device, or for decoration. The term ''flag'' is also used to refer to the graphic design employed, and fla ...
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
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 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
-compatible
CPUs.
Direction Flag
at MSDN
Microsoft Developer Network (MSDN) was the division of Microsoft responsible for managing the firm's relationship with developers and testers, such as hardware developers interested in the operating system (OS), and software developers developing ...
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
Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembe ...
, 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
An address is a collection of information, presented in a mostly fixed format, used to give the location of a building, apartment, or other structure or a plot of land, generally using border, political boundaries and street names as references, ...
; such instructions mode is called ''auto-incrementing'' mode. Both the source index and destination index (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