CrossWorks offers unaligned pointers, an extension to the ISO standard that enables 16-bit, 32-bit and 64-bit pointers to be used on byte aligned code and data memory.
An unaligned pointer is declared by placing the keyword __unaligned before the pointer declaration:
__unaligned unsigned short *sptr;
this can now be used with byte addresses for example
char x[10]; ... sptr = (__unaligned unsigned short *)(x+1); *sptr = 0x1234;
will assign x[1] to 0x34 and x[2] to 0x12. If you are using Packed structures then you must use __unaligned pointers when taking the address of a member for example
typedef __packed struct { char c; short s; } packed_structure_t; ... packed_structure_t ps; __unaligned short *sptr = (__unaligned short *)ps.s;
You can declare an unaligned pointer to code memory as follows
const __code short carr[3]; ... const __unaligned __code short *csptr = (const __unaligned __code short *)carr+1;