Keil™, An ARM® Company

Cx51 User's Guide

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
SMALLdatadatadata*3 bytes
COMPACTpdatapdatapdata*3 bytes
LARGExdataxdataxdata*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.