Keil Logo

Compact Model

Using the compact model, by default, all variables reside in a single page of external data memory of the 8051 system—as if they were explicitly declared using the pdata memory type specifier. This memory model can accommodate a maximum of 256 bytes of variables. The limitation is due to the addressing scheme used which is indirect through registers R0 and R1 (@R0, @R1).

This memory model is not as efficient as the small model and variable access is not as fast. However, the compact model is faster than the large model.

When using the compact model, the C51 Compiler accesses external memory with instructions that use the @R0 and @R1 operands. R0 and R1 are byte registers and provide only the low-order byte of the address.

If your target hardware has more than 256 bytes of external memory, the high-order address byte (or page) is provided by Port 2 on most 8051 devices (check your data sheet to confirm this). You must initialize Port 2 with the proper external memory page (in the startup code) and you must specify the starting address for PDATA to the linker.

Related Knowledgebase Articles

  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.