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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>TASKING</strong> <strong>VX</strong>-<strong>toolset</strong> <strong>for</strong> <strong>8051</strong> <strong>User</strong> <strong>Guide</strong>Macro__VERSION____<strong>VX</strong>__DescriptionIdentifies the version number of the compiler. For example, if you use version2.1r1 of the compiler, __VERSION__ expands to 2001 (dot and revisionnumber are omitted, minor version number in 3 digits).Identifies the <strong>VX</strong>-<strong>toolset</strong> C compiler. Expands to 1.Example#ifdef __C51__/* this part is only compiled <strong>for</strong> the <strong>8051</strong> <strong>VX</strong>-<strong>toolset</strong> compiler */...#endif1.7. Variables1.7.1. Automatic VariablesIn non-reentrant functions recursion is not possible, because automatic variables are not allocated on astack, but in a static area. The static area of a function can be overlaid with that of another function. Thissaves memory. Depending on the selected memory model the static area <strong>for</strong> automatics will be allocatedin the data, pdata or xdata memory space <strong>for</strong> the memory models small, auxiliary or large respectively.In a reentrant function automatic variables are treated the conventional way: dynamically allocated on astack. As is the case <strong>for</strong> the static area the place of the stack depends upon the selected memory model,it can be allocated in the data, pdata or xdata memory space.Although automatic variables are allocated in a static area <strong>for</strong> non-reentrant functions, they are not thesame as local variables (within a function) which are declared to be static by means of the keywordstatic. When the keyword static is used, a variable will keep its value when a function returns andis called again. This is not the case <strong>for</strong> automatic variables allocated in the static area, because the areamay be overlaid with the static area of another function.To generate code which is as fast and compact as possible, the compiler tries to place some automaticvariables into registers and in the internal RAM (extended virtual registers, also known as pseudo registers).By default, the compiler uses four bytes per function <strong>for</strong> pseudo registers. You can change this amountby means of the C compiler option --extend=size or #pragma extend size.For non-reentrant functions the static area <strong>for</strong> the pseudo registers will be overlaid, like the static area<strong>for</strong> automatic variables.For reentrant functions the area <strong>for</strong> the pseudo registers is as large as required <strong>for</strong> the function that usesthe most pseudo registers. Reentrant functions save/restore the pseudo registers on the stack, like theyare real registers.The C library is built in such a way that no pseudo registers are used. I.e: it is built with the option--extend=0.28

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

Saved successfully!

Ooh no, something went wrong!