Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
Direction flag
Flag stored in the FLAGS register on all x86-compatible CPUs

The direction flag is a flag that controls the left-to-right or right-to-left direction of string processing, stored in the FLAGS register on all x86-compatible CPUs. 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 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.
x86-instructionMeaningFlagNotes
Direction

of string processing

Mode title
CLDclear direction flag0lowest-to-highest addressauto-incrementing
STDset direction flag1highest-to-lowest addressauto-decrementing
We don't have any images related to Direction flag yet.
We don't have any YouTube videos related to Direction flag yet.
We don't have any PDF documents related to Direction flag yet.
We don't have any Books related to Direction flag yet.
We don't have any archived web articles related to Direction flag yet.

References

  1. 3.8.1 Carry and Direction Flag Control Instructions http://www.logix.cz/michal/doc/i386/chp03-08.htm

  2. Direction Flag at MSDN https://docs.microsoft.com/en-us/cpp/c-runtime-library/direction-flag