Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: Cpu Flags?

  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    40
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Cpu Flags?

    Hello CF

    I got 1 question. and only 1!

    What do you use FLAGS to?

    Regards,

    Nap

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You are going to have to give us more than that. What flags are you referring to? And on what type of CPU?
    OracleGuy

  • #3
    New Coder
    Join Date
    Oct 2010
    Posts
    40
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oracleguy View Post
    You are going to have to give us more than that. What flags are you referring to? And on what type of CPU?
    32-bit x86 EFLAGS just what are they there for? And what can you use them to do?

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    They hold the current status of the processor. For a detailed explanation see section 3.4.3 in volume 1 of the Intel 64 and IA-32 Architectures Software Developer's Manual. Appendix A also has a grid that shows what instructions will set or clear what flags.

    You really only need to worry about the flags when doing assembly level programming.
    OracleGuy

  • #5
    New Coder
    Join Date
    Oct 2010
    Posts
    40
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oracleguy View Post
    They hold the current status of the processor. For a detailed explanation see section 3.4.3 in volume 1 of the Intel 64 and IA-32 Architectures Software Developer's Manual. Appendix A also has a grid that shows what instructions will set or clear what flags.

    You really only need to worry about the flags when doing assembly level programming.
    I know, but i dont see the point in them? What do we need them for?
    Last edited by Napsteren; 12-20-2010 at 10:01 PM.

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by Napsteren View Post
    I know, but i dont see the point in them? What do we need them for?
    So you know when certain things have happened.

    For example if an add results in an overflow, the overflow can be handled if it matters. Some of the other control flags can be used to tell the processor to do different things when executing certain instructions like the direction flag.

    Different processor architectures have different status and control flags but they all typically have them in some form or another.
    OracleGuy

  • #7
    New Coder
    Join Date
    Oct 2010
    Posts
    40
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oracleguy View Post
    So you know when certain things have happened.

    For example if an add results in an overflow, the overflow can be handled if it matters. Some of the other control flags can be used to tell the processor to do different things when executing certain instructions like the direction flag.

    Different processor architectures have different status and control flags but they all typically have them in some form or another.
    ok. So what they do is, to tell what have happend after an execution of a program or code line. But why do we need to know this? I mean like the ZF flag why do i need to know if a opration result becomes zero?
    Last edited by Napsteren; 12-20-2010 at 11:34 PM.

  • #8
    Regular Coder
    Join Date
    Jun 2003
    Location
    Silicon Forest
    Posts
    155
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Most of the time you probably don't care about the ZF. But sometimes you are working with low level operations (usually the assembly level) and you might care. Maybe you wanted to set another variable based on the ZF that you were intending to use later, thus saving you an instruction. At the end of the day, it's all about giving you more control. Many of these flags also yield some possible compiler optimizations if it realizes it can replace several instructions with simply a flag test.

    The most common flag that you might use would be the overflow flag. This could have important ramifications even in high level code.
    Whats the point of a signature?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •