This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

#define COUNT 2000

can any one give me the meaning of following line

#define COUNT  2000
#define KEY2    0x2F
#define KEY1    0xF8

COUNT,KEY2,KEY1 are the name's given which we going to use next in the prog. but what is 2000,0x2F,0xF8 is address i.e memory location or simply just value.

Parents
  • Hmmm... don't know what went wrong there!!

    #define LEN 128
    


    defines a macro named LEN. When LEN is used in your program (or in preprocessor directives) it is replaced with the text 128.

    That is all it does - nothing more, nothing less.
    The preprocessor simply goes through your source text; everywhere it finds "LEN" it replaces it with "128"

    This is basic 'C' stuff - nothing specifically to do with Keil, embedded systems, or the 8051.
    You need to go back to your 'C' textbook.

    "KEY2 0x2F means port location address"

    It has no specific meaning at all - it is just a pure text substitution.
    You (or the author of the code) may choose to use it with that meaning, but it is not inherent in the #define you show

    "val 0xF8 means read the value from given address"

    No: again, it says nothing about reading, values, or addresses.

Reply
  • Hmmm... don't know what went wrong there!!

    #define LEN 128
    


    defines a macro named LEN. When LEN is used in your program (or in preprocessor directives) it is replaced with the text 128.

    That is all it does - nothing more, nothing less.
    The preprocessor simply goes through your source text; everywhere it finds "LEN" it replaces it with "128"

    This is basic 'C' stuff - nothing specifically to do with Keil, embedded systems, or the 8051.
    You need to go back to your 'C' textbook.

    "KEY2 0x2F means port location address"

    It has no specific meaning at all - it is just a pure text substitution.
    You (or the author of the code) may choose to use it with that meaning, but it is not inherent in the #define you show

    "val 0xF8 means read the value from given address"

    No: again, it says nothing about reading, values, or addresses.

Children