4.2.7 Section Address Operators

Table 3.26 lists the section address operators.

Table 4.25

Section Address Operators

No.

Section Address Operator

Description

1

__sectop("<section name>")

Refers to the start address of <section name>.

2

__secend("<section name>")

Refers to the sum of the size of <section name> and the address where <section name> starts.

3

__secsize("<section name>")

Refers to the size of <section name>.

[Return value type]

The return value type of __sectop is void *.

The return value type of __secend is void *.

The return value type of __secsize is unsigned long.

 

[Example]

(1) __sectop, __secend

#include <machine.h>

#pragma section $DSEC

static const struct {

void *rom_s; /* Start address of the initialized data section in ROM */

void *rom_e; /* End address of the initialized data section in ROM */

void *ram_s; /* Start address of the initialized data section in RAM */

} DTBL[]={__sectop("D"), __secend("D"), __sectop("R")};

 

#pragma section $BSEC

static const struct {

void *b_s; /* Start address of the uninitialized data section */

void *b_e; /* End address of the uninitialized data section */

} BTBL[]={__sectop("B"), __secend("B")};

 

#pragma section

#pragma stacksize si=0x100

#pragma entry INIT

void main(void);

void INIT(void)

{

_INITSCT();

main();

sleep();

}

(2) __secsize

/* size of section B */

unsigned int size_of_B = __secsize("B");

[Remarks]

In an application that enables the PIC/PID function, __sectop and __secend is processed as the addresses determined at linkage.

For details of the PIC/PID function, refer to the descriptions of the pic and pid options in Usage of PIC/PID Function.