Keil Logo

Memory Models

The memory model determines the default memory type to use for function arguments, automatic variables, and declarations that include no explicit memory type. The C51 Compiler provides three memory models:

The following table lists the default memory areas used for each memory model.

Memory
Model
Parameters &
Automatic
Variables
Default
Global
Variables
Default
Constant
Variables
Default
Pointer
Definitions
Default
Pointer
Size
SMALL data data data * 3 bytes
COMPACT pdata pdata pdata * 3 bytes
LARGE xdata xdata xdata * 3 bytes

You may specify the memory model on the compiler command line using the SMALL, COMPACT, or LARGE directives or using #pragma in the source file. You may also specify the memory model on a function-by-function basis by adding the memory model to the function declaration.

Note

  • Except in very special select applications, the SMALL memory model generates the fastest, most efficient code.

You may override the default memory type imposed by the memory model by explicitly declaring a variable with a memory type specifier.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.