Mixed Memory Models

C51 v6.03+; uVision v2.07+

I want to build a Project with some files using the SMALL model, but most using LARGE.

If I select LARGE in the Target options, and specify SMALL in the C51 'Misc Controls' where required, or use a #pragma in the file itself, I get a fatal Compiler error:

RESPECIFIED OR CONFLICTING CONTROL

If I select SMALL in the Target options, and specify LARGE in the C51 'Misc Controls' box where required, everything Compiles OK, but I get Linker warnings for each of the 'Large' Modules:
L14: INCOMPATIBLE MEMORY MODEL

If I specify 'large' in each function declaration where required, it all Compiles and Links OK!

Thus it is possible to create a mixed-model Project, but extremely cumbersome to have to specify the model on every function!
Why doesn't it work when the model is specified at the module level?

(yes, I know you wouldn't want to design a Project like this from scratch, but this is "inherited" stuff...)

Parents
  • The problem is this:

    If you have a file (compiled in SMALL memory model) and another file (compiled in LARGE memory model) and both files call the printf library routine...which printf routine is included from the library? The LARGE model printf or the SMALL model printf?

    The answer is that this is an error condition.

    The memory model applies to the WHOLE program. It specifies not only the default variables space for YOUR functions but also the default variable space for the LIBRARY routines.

    When you create a program, you may specify the memory model on a function-by-function basis. For example:

    int my_func (int a, int b, int c) large
    

    But, you should note that any library routines that my_func calls are the small model versions.

    Jon

Reply
  • The problem is this:

    If you have a file (compiled in SMALL memory model) and another file (compiled in LARGE memory model) and both files call the printf library routine...which printf routine is included from the library? The LARGE model printf or the SMALL model printf?

    The answer is that this is an error condition.

    The memory model applies to the WHOLE program. It specifies not only the default variables space for YOUR functions but also the default variable space for the LIBRARY routines.

    When you create a program, you may specify the memory model on a function-by-function basis. For example:

    int my_func (int a, int b, int c) large
    

    But, you should note that any library routines that my_func calls are the small model versions.

    Jon

Children
More questions in this forum