callt function (#pragma callt)


This notifies the compiler of a callt function.

[Function]

-

A function specified with #pragma callt is called by the callt instruction.
The callt instruction enables a function whose "start address of function definition" is stored in the area (0x80 to 0xBF) called as the callt instruction table to be called by a shorter code than a direct function call.

-

The callt function is called by the callt instruction using a label name with "@_" added to the beginning of the function name.
When the callt function is called at the end of a function, the callt instruction is not used to make the call in some cases.

-

The called function is handled as a normal function in the C source program.

-

The specification becomes __near, and address reference always returns a near pointer.

-

The callt function is allocated to a section with the relocation attribute TEXT.

-

The callt instruction table is allocated to the .callt0 section.

-

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

-

When #pragma callt, #pragma near, or #pragma far was specified together for the same function, the #pragma directives become valid in the priority order of #pragma callt > #pragma near > #pragma far.

[Effect]

-

The size of the object code becomes smaller because the function is called by a 2-byte call instruction.

[Usage]

-

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

#pragma callt [(]function-name[,...][)]

[Restrictions]

-

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

-

If a #pragma directive other than #pragma near or #pragma far is specified for the same function, a compilation error will occur.

-

If __inline and __callt are specified in the declaration of a target function of this #pragma directive, a compilation error will occur.

[Example]

#pragma callt callt_func1
extern void callt_func1(void);
 
void func1(void)
{
        callt_func1();
          :
}
 
#pragma callt callt_func2
extern void __far callt_func2(void);  // Becomes __near without a warning 
                                      // due to the effect of #pragma callt
void func2(void)
{
        callt_func2();
          :
}

[Remark]

-

Difference between the __callt keyword and #pragma callt

-

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

-

#pragma callt handles even a function to which the __far keyword is added as if __callt was specified without a warning being output.