11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

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

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

C Language FeaturesFiles3.3.4.1 Initialization of Data psectsOne job of the runtime startup code is ensure that any initialized variables contain their initial valuebefore the program begins execution. Initialized variables are those which are not auto objects andwhich are assigned an initial value in their definition, for example input in the following example.int input = 88;void main(void) { ...•Since auto objects are dynamically created, they require code to be positioned in thefunction in which they are defined to perform their initialization. It is also possible thattheir initial value changes on each instance of the function. As a result, initialized autoobjects do not use the data psects.Such initialized objects have two components and are placed within the data psects.The actual initial values are placed in a psect called idata. The other component is where thevariables will reside, and be accessed, at runtime. Space is reserved for the runtime location ofinitialized variables in a psect called data. This psect does not contribute to the output file.The runtime startup code performs a block copy of the values from the idata to the data psectso that the RAM variables will contain their initial values before main() is executed. Each locationin the idata psect is copied to appropriate placed in the data psect.The block copy of the data psects may be omitted by disabling the init suboption of --RUNTIME.For example:--RUNTIME=default,-initWith this part of the runtime startup code absent, the contents of initialized variables will be unpredictablewhen the program begins execution. Code relying on variables containing their initial valuewill fail.Variables whose contents should be preserved over a reset, or even power off, should be qualifiedwith persistent, see Section 3.4.9.1. Such variables are linked at a different area of memory and arenot altered by the runtime startup code in any way.3.3.4.2 Clearing the Bss PsectsThe ANSI standard dictates that those non-auto objects which are not initialized must be clearedbefore execution of the program begins. The compiler does this by grouping all such uninitializedobjects into a bss psect. This psect is then cleared as a block by the runtime startup code.27

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

Saved successfully!

Ooh no, something went wrong!