We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello gurus!
I am developing code for an 8051 variant with 2K of on-chip XDATA and 32K of flash.
Question 1:
I have compiled the entire project with memory model as "large". I am trying to see the effect of using "small" memory model for a specific file. What I have learned from Keil's help is, and I quote "These directives apply to the entire source file and may be specified only once on the command line or at the beginning of the source file using the #pragma statement. They may not be used more than once in a source file. "
I am trying to use #pragma small at the top of my C file, but it gives the error:
ACTION: PARSING INVOKE-/#PRAGMA-LINE LINE: #pragma SMALL ERROR: RESPECIFIED OR CONFLICTING CONTROL
I have even tried specifying "small" in the individual options for the file (under C51 tab), but to no avail. What is my mistake ? What is the correct method ?
Question 2:
I have about 1.9KB of variables in XDATA, which have been declared as "volatile unsigned char xdata bla_bla;". In order to use them in other files, their respective "extern" declarations are written in a header file and included in all C files, e.g.:
"extern volatile unsigned char xdata bla_bla;"
Is there a need to specify "volatile" keyword in the extern declaration as well ? If I remove the "volatile" keyword from the "extern" declaration, I save about 400 bytes of source code. When "volatile" has been specified as part of the actual definition, why does "volatile" in extern affect the code size ?
Hoping a quick response from all the gurus....
Regards Aman