OPT attribute

Top  Previous  Next

This attribute of the TASK statement provides a way to give instructions or preferences to the configurer about how you wish memory allocation to be carried out. It has three forms, as shown in these examples:

 

task first  opt=stack opt=seg_red

task second opt=stack:highram

task third  opt=seg_blue:0x28000

 

The first form asks the configurer to place one logical area, stack, and one user-defined section, seg_red, in the fastest memory possible. The fastest is, of course, the on-chip memory.

 

The second asks that a logical section, stack, should be placed in a named physical memory area, highram. Which physical areas you may specify depends on the processor type; for details, you should consult your board documentation.

 

The third form asks for the user-defined section, seg_blue, to be loaded at the specified physical address. It is extremely rare for this form ever to be needed; the other forms are nearly always adequate.

 

Dragons003Beware of placing sections at address 0. This can result in objects having a zero address which may be interpreted as a NULL pointer. For example, an array of char placed at 0 cannot be output using printf as the argument is seen as a NULL pointer and interpreted as an empty string.

 

Using either of the first two forms of this attribute does not guarantee that what you have requested will in fact happen. The OPT attributes of all the various tasks on a processor, the sizes of their logical areas and the sizes of the physical areas available are all taken into account by the configurer when it performs the memory allocation.

 

As well as the standard logical area names, CODE, DATA, STACK, HEAP and STATIC, you can specify named sections of the task, defined by the programmer. Where such sections have names that do not conform to the configurer’s conventions for identifiers, you must enclose the name in quotes:

 

Task fourth opt= ".tables"