12.07.2015 Views

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM 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.

C LanguagePacked structuresTo prevent alignment gaps in structures, you can use the attribute __packed__. When you use theattribute __packed__ directly after the keyword struct, all structure members are marked __unaligned.For example the following two declarations are the same:struct __packed__{char c;int * i;} s1;struct{char __unaligned c;int * __unaligned i; /* __unaligned at right side of '*' to pack pointer member} s2;The attribute __packed__ has the same effect as adding the type qualifier __unaligned to thedeclaration to suppress the standard alignment.You can also use __packed__ in a pointer declaration. In that case it affects the alignment of the pointeritself, not the value of the pointer. The following two declarations are the same:int * __unaligned p;int * p __packed__;Change alignmentWith the attribute __align(n) you can overrule the default alignment of objects or structure membersto n bytes.1.3. Placing an Object at an Absolute Address: __at()With the attribute __at() you can specify an absolute address.The compiler checks the address range, the alignment and if an object crosses a page boundary.Examplesunsigned char Display[80*24] __at( 0x2000 );The array Display is placed at address 0x2000. In the generated assembly, an absolute section iscreated. On this position space is reserved <strong>for</strong> the variable Display.int i __at(0x1000) = 1;The variable i is placed at address 0x1000 and is initialized.void f(void) __at( 0xf0ff + 1 ) { }The function f is placed at address 0xf100.3

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

Saved successfully!

Ooh no, something went wrong!