FLAGS Register (computing) - Use

Use

The POPF, POPFD, and POPFQ instructions read the first 16, 32, and 64 bits of the flags register, respectively. POPFD was introduced with the i386 architecture and POPFQ with the x64 architecture. In 64-bit mode, PUSHF/POPF and PUSHFQ/POPFQ are available but not PUSHFD/POPFD.

The following assembly code changes the direction flag (DF):

mov bx, 400h ; Set the DF fl pushf ; Pushes the current flags onto the stack pop ax ; Pop the flags from the stack into ax register push ax ; Push them back onto the stack for storage xor ax, bx ; XOR dest, src | Used for toggling the DF flag only, keep the rest of the flags push ax ; Push again to add the new value to the stack popf ; Pop the newly pushed into the FLAGS register ; ... Code here ... popf ; Pop the old FLAGS back into place

In practical software, the cld and std mnemonics are used to clear and set the direction flag, respectively.

Read more about this topic:  FLAGS Register (computing)

Famous quotes containing the word use:

    ... it is use, and use alone, which leads one of us, tolerably trained to recognize any criterion of grace or any sense of the fitness of things, to tolerate ... the styles of dress to which we are more or less conforming every day of our lives. Fifty years hence they will seem to us as uncultivated as the nose-rings of the Hottentot seem today.
    Elizabeth Stuart Phelps (1844–1911)