11.07.2015 Views

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVRFunction PointersTo be fully compatible with <strong>the</strong> Code Compressor (tm), all indirect function referencesmust be through an extra level of indirection. This is done automatically <strong>for</strong> you in C ifyou invoke a function by using a function pointer. In o<strong>the</strong>r words, function pointersbehave as expected, with <strong>the</strong> exception of being slightly slower.The following assembly language example illustrates this:; assume _foo is <strong>the</strong> name of <strong>the</strong> function.area func_litPL_foo:: .word _foo ; create a function table entry.area textldi R30,PL_foorcall xicallYou may use <strong>the</strong> library function xicall to call <strong>the</strong> function indirectly after putting <strong>the</strong>address of <strong>the</strong> function table entry into <strong>the</strong> R30/R31 pair. Function table entries are putin a special area called func_lit. See Program Areas.For <strong>the</strong> M256x targets, <strong>the</strong> function tables are located in <strong>the</strong> efunc_lit area <strong>and</strong>each entry is 3 bytes long, to allow <strong>the</strong> function to be located anywhere in <strong>the</strong> 256Kbytes address space. The function exicall is used instead of xicall, since 3 bytesare used.145

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

Saved successfully!

Ooh no, something went wrong!