13.07.2015 Views

TASKING VX-toolset for 8051 User Guide

TASKING VX-toolset for 8051 User Guide

TASKING VX-toolset for 8051 User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>TASKING</strong> <strong>VX</strong>-<strong>toolset</strong> <strong>for</strong> <strong>8051</strong> <strong>User</strong> <strong>Guide</strong>1.10. FunctionsStatic and Reentrant FunctionsFor the <strong>8051</strong> <strong>VX</strong>-<strong>toolset</strong> functions in C can either be static or reentrant. In static functions parametersand automatic variables are not allocated on a stack, but in a static area. Reentrant functions use a lessefficient virtual dynamic stack which allows you to call functions recursively. With reentrancy, you can callfunctions at any time, even from interrupt functions. The compiler can overlay parameters and automaticsof static functions, but not of reentrant functions.See also Section 1.7.1, Automatic Variables.You can use the function qualifiers __static or __reentrant to specify a function as static or reentrant,respectively. If you do not specify a function qualifier, the compiler assumes that those functions are static.If you specify the compiler option --reentrant the default <strong>for</strong> functions without a function qualifier isreentrant.Example:void f_static( void ){/* this function is by default __static */}__reentrant int f_reentrant ( void ){int i;/* variable i is placed on a virtual stack */}1.10.1. Calling ConventionParameter PassingA lot of execution time of an application is spent transferring parameters between functions. The fastestparameter transport is via registers. There<strong>for</strong>e, function parameters are first passed via registers. If nomore registers are available <strong>for</strong> a parameter, the compiler pushes parameters on the stack (a static orreentrant stack depending on the __reentrant function qualifier).The following conventions are used when passing parameters to functions.Registers available <strong>for</strong> parameter passing are B.0 .. B.7, R2, R3, R4, R5, R6, and R7. Parameters

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!