Forum Discussion
Altera_Forum
Honored Contributor
15 years agoI'm not sure that you'll find it easy to emulate the mis-aligned transfer in the ISR. You'll need to look at the interrupted instruction and 'hand' decode it, then get the appropriate register values from the saved registers to preform the required memory transfers.
You are better off shooting the person who used 'packed' for the structures! One option might be to encapsulate the misaligned 'int' in a structure. Then fix all the code (changing the type of the pointer, and using access defines) so that the code compiles. The compiler will then generate the required code for the misaligned accesses. I don't think it is possible to generate a 'pointer to a misaligned int', you can only have misaligned structure members. It is also possible to the __attribute__((aligned(1))) to mark single structure members as having bytes alignment while still assuming the structure itself is aligned - ie not forcing misaligned accesses on all fields. (Also useful to force an alignment of 2)