What is the difference between the following two variable declaration?
unsigned char var; and unsigned char data var;
"According to me, all operations with that variable will be done with a "garbage" value."
Yes, that's right.
If you tell the tools to use XRAM they will do so. As Erik says, they have no way of knowing what may or may not be present in your target hardware - they just do as they are told.
Now what if there isnt any external memory IC (RAM) connected & you select a model other than SMALL?
Your question implies is that the assembler/compiler/linker should 'know' what you have, it does not, unless you tell it what you have.
Erik
Yes exactly. Now I have understood it properly.
According to me, all operations with that variable will be done with a "garbage" value.
"The memory alocation depends on the 'memory model'"
The first one depends upon the memory model; the second one doesn't, because it specifies the memory space explicitly.
Hello Sir,
Got the difference. The memory alocation depends on the "memory model" you select. Accordingly, a byte will be allocated at the appropriate place.
Thank you for the link.
Regards, Dipen
Will do thru the link... & will get back to you incase of further queries...
Thank you.
"In both the cases, wont the memory allocation for "var" be in the RAM? Then how do the two differ?"
Alright then, more specifically, without 'data', var is allocated in the default RAM memory space according to the memory model you have selected. With 'data', var is explicitly allocated in the internal RAM's directly addressable data memory space.
You need to read your User's Guide.
http://www.keil.com/support/man/docs/c51/c51_extensions.htm
In both the cases, wont the memory allocation for "var" be in the RAM? Then how do the two differ?
Could you explain - allocation in default memory space according to the memory model...?
Without 'data', var is allocated in the default memory space according to the memory model you have selected. With 'data', var is explicitly allocated in the data memory space.
View all questions in Keil forum