Using __declspec(far_call)

The __declspec(far_call) is provided as a means of directly annotating a function to be called by a register direct call. To use this annotation prepend the __declspec to the function prototype or definition.

Listing: Example of using __declspec(far_call)

__declspec(far_call) extern void function1(void);

int main()

{

    function1();    // generate BLX 
Rm (or BX rm)

}

or

__declspec(far_call) void function1(void)

{

}

int main()

{

    function1();    // generate BLX 
Rm (or BX rm)

}

The compiler does not generate the BLX Rm instruction in the following 
case because the __declspec(far_call) attribute is overwrited by the 
function definition.

__declspec(far_call) extern void function1(void);

void function1(void)

{

}

void main()

{

    function1();    // generate BL

}