Using saddr area (#pragma saddr)


This notifies the compiler of a variable that is to be assigned to the saddr area.

[Function]

-

Initialized variables are allocated to the .sdata section.

-

Uninitialized variables are allocated to the .sbss section.

-

Address reference always returns a near pointer.

-

External variables and static variables in a function are allocated to the saddr area when they are specified with #pragma saddr.

-

#pragma saddr handles even a variable to which the __far keyword is added as if __near was specified without a warning being output.

[Effect]

-

Instructions that access the saddr area are shorter than those accessing the normal memory area and their object code also becomes smaller, leading to improved execution speed.

[Usage]

-

Declare #pragma saddr before the first declaration of a variable.

#pragma saddr [(]variable-name[,...][)]

[Restrictions]

-

If there are multiple declarations for the same variable and #pragma saddr is written at the location where the second or subsequent declaration takes effect, correct operation is not guaranteed.

-

If another #pragma is specified, a compilation error will occur.

[Example]

#pragma saddr saddr_var
extern int saddr_var;
 
void func(void)
{
        saddr_var = 0;
}

[Remark]

-

Difference between the __saddr keyword and #pragma saddr

-

The __saddr keyword cannot be used together with the __near or __far keyword, and a compilation error will occur if used so.

-

#pragma saddr handles even a variable to which the __near or __far keyword is added as if __saddr was specified without a warning being output.