Forum Discussion
Altera_Forum
Honored Contributor
15 years agoDo you also have a byte endianness issue?
We wrote a single custom instruction that uses the 'b' field (usually a custom instruction register number) to select between various bit and byte swaps (more useful than the Altera instruction). If you are processing SCSI commands then, IIRC, you have a 32bit value that is 2-byte aligned. Applting __attribute__((aligned(2))) to that field (of the structure that defines the message layout) should make gcc generate two 16bit load/stores with the required shifts. (If you apply 'packed' to the entire structue all fields will be read as bytes since the alignment of the structure itself is unknown.) I've just done a quick test (with gcc 3.4.6) the __attribute__((aligned(1))) works - for arrays and structure members, but not simple variables. Feed:int v __attribute__((aligned(2)));
int get_v(void) { return v; };into gcc -O2 -S and cat the .s file.