Keil Logo

C166: LOCATING MORE VARIABLES IN THE NEAR MEMORY AREA


Information in this article applies to:

  • C166 All Versions

QUESTION

I'm migrating a working C166 application from the TINY memory model (near code & near data) to the COMPACT memory model (near code & far data). The tools have split my RAM usage between near memory and far memory even though these memory spaces occupy the same address range.

Here are my questions.

  1. How is the range set for the NEAR and FAR data memory?
  2. What strategy does the linker use to locate my data segments?
  3. How can I control how segments are placed into these memory areas?
  4. The code size of my application increased from 20k to 23k. If I can get the linker to place more of my data in the NEAR area, will the code size shrink because NEAR data is accessed using 16-bit addresses?

ANSWER

  1. In µVision, if you use the target options window to specify your memory areas, the ranges for the data area are set automatically. So, if you select the COMPACT memory model, the NEAR and FAR data areas are set to the same address space. You can use the L166 Locate dialog in the Project Options dialog to manually set the address ranges for each memory class. You must un-check the Use Memory Layout from Target Dialog to do that.
  2. The strategy used is described in the L166 Linker User's Guide. Basically, the linker combines all NEAR segments and all FAR segments together as you would expect.
  3. Use the HOLD compiler directive to specify the maximum size of objects placed in the NEAR memory. In the µVision Project Options dialog, you may specify this in the Data Threshold input line in the Target Options dialog.
  4. Yes. Accessing variables in NEAR memory always takes less code than accessing data in FAR memory.

MORE INFORMATION

Last Reviewed: Tuesday, July 31, 2018


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  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.