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.
"can any one give me the meaning of following line"
Other than the author or provider of the software, no.
"or simply just value."
As far as the snippet you've provided goes, they are just values. How they might subsequently be used (or abused) elsewhere is completely impossible to tell!
Today's lesson is: always fully comment all definitions!
The comments should answer your questions!
i have some sample prog. in that some are act like address while some are limit's value(higher and lower limit value) some number's are used twise or thrise that are definatly not addresses. they are also not a value. so what is that
That is all totally valid!
Numbers in and of themselves are abstract!
Even in real life, No pure number ever has any meaning in itself - only when you know the context does it become meaningful.
eg, "three" on its own is meaningless; it only gains meaning when you know what the "three" relates to - three apples, or three miles, or house number three, or third turning, etc, etc, etc,...
Do you actually understand what #define does?
Simple Macros A simple macro is merely an abbreviation for a fragment of code. It is often called a manifest constant because it defines a name for a constant value. Macros must be defined using the #define directive before they can be used. For example: #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. So, a C statement like char buffer[LEN]; is expanded by the preprocessor into char buffer[128]; and is subsequently compiled by the compiler.
i read the above and most cover the all related topic of this wher the link put me
"i read the above"
Good.
And did you understand it?
Are you now clear why it is totally impossible to answer your original question?
Are you now able to go back to your "sample" code and see what it is doing?
i uderstand little bit
#define COUNT 2000 #define KEY2 0x2F #define val 0xF8
COUNT 2000 means value assign to COUNT KEY2 0x2F means port location address val 0xF8 means read the value from given address
"i uderstand little bit"
No, apparently you don't.
"COUNT 2000 means value assign to COUNT"
No, it doesn't. There is no assignment here.
re-read the text that you pasted earlier:
#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.
Hmmm... don't know what went wrong there!!
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.
#define COUNT 2000
it mean's when ever the COUNT appears replace it with 2000;
#define val 0x0f
it mean's when ever the val appears goto the memory location 0x0f and pop-up the value
or it's meaning is totally un explanable because it know's only by auther
"its meaning is totally un explanable because it known only by author"
Absolutely - if the author is thoughtless enough to not provide any documentation (whether in the form of comments ot otherwise).
As you say this is "sample" code, you need to ask yourself whether your time is going to be better spent trying to understand the "sample", or if you'd be better off just writing it yourself from scratch!
do not waste time "asking yourself", you WILL "be better off just writing it yourself from scratch"
The only value of "sample" code I know of comes after you have written the code for what you want to do yourself. At such time you understand what it is all about and, at that time, sometimes - not always a look at "sample" code can give a hint to where the error in what you wrote is.
Erik
i have put one more question in forum can u answer that sinciarly i.e. truly
can u answer that sinciarly who would know if micro can asnwer but himself?
I think your time would be better spent in studying your 'C' textbook rather than worrying about Keil's internal policies!
http://www.keil.com/forum/docs/thread8516.asp
sorry but there is some thing that u don't know and on that thing u r working
y r u 2 la-z 2 rite "you" etc?
just in case, as so often it is, the poster can not understand "back at you" here it is spelled out
If you are too lazy to write you, why should we not be too lazy to answer?
"As you say this is "sample" code, you need to ask yourself whether your time is going to be better spent trying to understand the "sample", or if you'd be better off just writing it yourself from scratch!"
Then what will the other person do, sit jobless?
"Better off just writing it yourself from scratch!" Then i wonder what is there for the other person to do, to sit jobless?
"Then what will the other person do, sit jobless?"
What other person?
If you mean the one who provided the "sample", then they ought to be fired for writing such rubbish, and setting such a bad example!
"If you mean the one who provided the "sample", then they ought to be fired for writing such rubbish, and setting such a bad example!" Thats right, So, i'l fire the "sample program" for giving all the trouble ... why i never thought about it earlier...
Then i wonder what is there for the other person to do, to sit jobless ?
writing "sample code" and publishing it on the net so anyone can use it fro free is hardly a "job"
If, however YOU are "the other person" and will "sit jobless" unless there is code to copy beacuse you are incapable of writing it yourself --- tough luck,
"why i never thought about it earlier..."
Why? Just not thinking about all options, I suppose.
You are the one person who's got an answer for every question on this forum
Not bad,
View all questions in Keil forum