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

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

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

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVRAssembly Interface <strong>and</strong> Calling ConventionsExternal NamesExternal C names are prefixed with an underscore. For example, <strong>the</strong> function main is_main if referenced in an assembly module. Names are significant to 32 characters.To make an assembly object global, use two colons after <strong>the</strong> name. For example,_foo::.word 1.blkw 1(In <strong>the</strong> C file)extern int foo;Argument <strong>and</strong> Return RegistersIn <strong>the</strong> absence of a function prototype, integer arguments smaller than ints (<strong>for</strong>example, char) must be promoted to int type. If <strong>the</strong> function prototype is available,<strong>the</strong> C st<strong>and</strong>ard leaves <strong>the</strong> decision to <strong>the</strong> <strong>compiler</strong> implementation. ICCV8 <strong>for</strong> AVRdoes not promote <strong>the</strong> argument types if <strong>the</strong> function prototype is available.If registers are used to pass byte arguments, it will use both registers but <strong>the</strong> higherregister is undefined. For example, if <strong>the</strong> first argument is a byte, both R16/R17 will beused with R17 being undefined. Byte arguments passed on <strong>the</strong> software stack alsotake up 2 bytes. We may change <strong>the</strong> behavior <strong>and</strong> pack byte arguments tightly insome future release.The first argument is passed in registers R16/R17 if it is an integer <strong>and</strong> R16/R17/R18/R19 if it is a long or floating point. The second argument is passed in R18/R19 ifavailable. All o<strong>the</strong>r remaining arguments are passed on <strong>the</strong> software stack. If R16/R17is used to pass <strong>the</strong> first argument <strong>and</strong> <strong>the</strong> second argument is a long or float, <strong>the</strong>lower half of <strong>the</strong> second argument is passed in R18/R19 <strong>and</strong> <strong>the</strong> upper half is passedon <strong>the</strong> software stack.Integer values are returned in R16/R17 <strong>and</strong> longs <strong>and</strong> floats are returned in R16/R17/R18/R19. Byte values are returned in R16 with R17 undefined.142

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

Saved successfully!

Ooh no, something went wrong!