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

About constants



Can anybody tell me how constants

are stored in a 8051 application.

If it is prom- able to write it to the

PROM and how it will be accessed during

program execution? thanks.


regards,
san

Parents Reply Children
  • // Goes in RAM, not ROM. 
    const unsigned char tens[] = { 1, 10, 100, 1000, 10000, 100000 };
    Will be stored in the heap, never on the stack because it is outside the scope of a function (I assume). It will exist in DATA if you use the small model and XDATA if you use the large model. Personally, I'd explicitly specify the memory space as CODE or XDATA like this:
    const unsigned char code tens[] = { ... };
    It is global if you do not add the static keyword as in:
    static const unsigned char code tens[] = { ... };
    Static will make it global to the file but not the project. Leaving static off makes it global to the project. Defining 'tens' inside a function makes private to that function. Defining 'tens' inside a { } sequence inside a function makes it visible only inside the { } sequnce. Etc. I suggest you hang out in comp.lang.c as these are all just ISO C questions.

    Regards.

    - Mark