02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

VxWorks 5.5<br />

<strong>BSP</strong> Developer’s <strong>Guide</strong><br />

For example:<br />

struct aPackedStruct {<br />

UINT32 int1;<br />

INT16 aShort;<br />

INT8 aByte;<br />

} _WRS_PACK_ALIGN(1) anInstance={0x1,2,3};<br />

/* Bits in the aByte field */<br />

#define ABYTE_ERROR<br />

#define ABYTE_OFLOW<br />

#define ABYTE_UFLOW<br />

#define ABYTE_DMA<br />

#define ABYTE_POLL<br />

0x01<br />

0x02<br />

0x04<br />

0x08<br />

0x10<br />

8.1.2 In-Line Assembly<br />

In-line assembly is a more difficult issue because it involves both the compiler and<br />

the assembler. In Wind River’s case, the code base fortunately uses MIT assembler<br />

syntax throughout, which many assemblers are compatible with. In-line assembly<br />

in portable C code is by its nature not portable across architectures. Thus, the real<br />

question for in-line assembly is compiler portability.<br />

The current compilers differ significantly about how to include assembly<br />

instructions without interfering with, or suffering interference from, the<br />

compiler’s optimization efforts. In the absence of an ideal solution, in-line<br />

assembly should only be used if it does not interact with the surrounding C code.<br />

This means that acceptable in-line assembly does not interact with C variables or<br />

return values. Code that cannot meet this limitation should be written entirely in<br />

assembly language.<br />

The vxWorks.h header file defines a _WRS_ASM macro to be used to insert in-line<br />

assembly instructions in a C function.<br />

For example (PowerPC):<br />

VOID foo (void)<br />

{<br />

routineA (args);<br />

_WRS_ASM(“ eieio; isync;”);<br />

routineB (args);<br />

}<br />

Assume that the compiler is not free to optimize or reorder in-line assembly code<br />

with respect to surrounding C code.<br />

162

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

Saved successfully!

Ooh no, something went wrong!