Placing a pointer table at a specific address

Technical Note 44835

Targets:
All

Component:
Compiler

Updated:
1/30/2006 1:29 PM

Introduction

This Technical Note discusses how to place an array of pointers at a specific address.

Solution

In an IAR C/C++ Compiler version, which supports @ placement, there are two methods to use. Either declare the array as const or if values needs to be change at run-time declare the array as non-initialized.

The first method can look like

unsigned char * const RamAddresses[4] @ 0x8000 =
{
&object1,
&object2,
&object3,
&object4,
};

Second method

This method needs two actions.

The absolute placement (@ symbol) does not allow initialized non-const variables. So declare the array as __no_init.

__no_init unsigned char * RamAddresses[4] @ 0x8000;

Then in application code initialize the array, for example at the beginning of main().

RamAddresses[0] = &object1;
RamAddresses[1] = &object2;
RamAddresses[2] = &object3;
RamAddresses[3] = &object4;

All product names are trademarks or registered trademarks of their respective owners.

RELATED TECH NOTES

© IAR Systems 1995-2016 - All rights reserved.