Everything

callt function (__callt)


A function declared with __callt is called by the callt instruction.

[Function]

-

A function declared with __callt (callt function) 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.

[Effect]

-

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

[Usage]

-

The __callt declaration is made in the module that defines the function.

__callt function-declaration;
extern __callt  function-declaration;
static __callt  function-declaration;
__callt extern  function-declaration;
__callt static  function-declaration;

[Restrictions]

-

The callt function is allocated to addresses 0xC0 to 0xFFFF regardless of the memory model.

-

When __callt is specified for other than a function declaration, a compilation error will occur.

-

The number of callt functions is checked at linkage.

-

__callt needs to be specified for all declarations of the target function.
When there is a __callt specification for only some declarations, a compilation error will occur.

        void func(void);
__callt void func(void);          //Error

-

__callt can be specified simultaneously with __near but a compilation error will occur when it is specified simultaneously with __far.

__callt void func1(void);         //Function address is set to near
__callt __near void func2(void);  //Function address is set to near
__callt __far void func3(void);   //Error

-

When __callt is used in typedef, a compilation error will occur.

typedef __callt int    CI;        //Error

-

When there is a #pragma specification for a function that is qualified with __callt in the function declaration, a compilation error will occur.

[Example]

The following shows a sample C source code.

__callt void func(void){
          :
}
 
void main(void){
        func();    //Call of callt function
          :
}

 

The following shows the section allocation and output codes in the assembly source code.

        .PUBLIC _func
        .PUBLIC _main
        .PUBLIC @_func
          :
 
        .SECTION        .text,TEXT
_func:
          :
 
        .SECTION        .textf,TEXTF
_main:
        callt   [@_func]
          :
 
        .SECTION        .callt0,CALLT0
@_func:
        .DB2    _func
          :

[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.