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

Defaulting to HCONST and HDATA

C51 v7.20, Dallas DS80C400 in contiguous mode.
(not a regular 8051 memory architecture)

Using the LARGE memory model, is it possible to get the compiler to automatically assign variables to the HDATA class without specifying "far" everywhere?

char x; // goes to xdata by default
Obviously I can change it to:
char far x;
but I'd like to avoid that if possible and a scan of the archives here suggests that I'm going to have to use "far" everywhere. Can Keil confirm this please?




Likewise, is it possible to get constants going to the HCONST class instead of CODE?

The more conventional:
const char code x[]={1,2,3,4};
has to be replaced with:
const char far x[]={1,2,3,4};
If this has to be done, then fine - I can live with that - but is there a way to make "code" automatically go to "far" ? (other than #define code far (which I haven't tried yet because it will probably mess up other stuff)).




Perhaps more importantly:
printf("hello");
The string literal "hello" goes to CODE. Is there any way (automatic or otherwise) to get string literals to go to ECODE or HCONST ?

Parents
  • Consult the manual on
    #pragma STRING(FAR)


    Thanks, that's exactly what I need.

    Would still appreciate a definitive confirmation from Keil that there is no way to automatically shift all xdata variables, including storage of function call arguments for large functions, into far memory.

    I may end up having to move over 1000 variables into far depending on the outcome of some other issues I'm looking into.

Reply
  • Consult the manual on
    #pragma STRING(FAR)


    Thanks, that's exactly what I need.

    Would still appreciate a definitive confirmation from Keil that there is no way to automatically shift all xdata variables, including storage of function call arguments for large functions, into far memory.

    I may end up having to move over 1000 variables into far depending on the outcome of some other issues I'm looking into.

Children
  • Would still appreciate a definitive confirmation from Keil that there is no way to automatically shift all xdata variables, including storage of function call arguments for large functions, into far memory.

    I don't know of a way to do that. It's on the list of future enhancements but I don't have an ETA on when it will be added.

    So, for the time being, you'll have to define vars with a far keyword.

    My suggestion would be to create a #define so you can remove it or tweak it later.

    Jon

  • I don't know of a way to do that. It's on the list of future enhancements but I don't have an ETA on when it will be added. So, for the time being, you'll have to define vars with a far keyword.

    Thanks Jon, I suspected that would be the case.

    My suggestion would be to create a #define so you can remove it or tweak it later.

    Oh of course :-)

    The code in question is already multi-product and multi-platform (including non-8051 platforms) so there's already lots of #defines in place :-)