3006: 0c 8d sub r13, r12
3008: 30 41 ret
In spite of the type for offsets being an int, the compiler generates
code that fetches it a byte at a time and then shifts to combine. This
is with optimization on. (-O2) Looking at some other spots where I read
the information memory, it also reads it a byte at a time.
Why is it being so stupid? Even the shift is stupid since a single swpb
would do the trick.
The TI version of gcc doesn't have the hooks to linker defined symbols
like mspgcc did so I edited the linker script to provide symbols
defining the information memory. I also used the now missing crtld.h as
a guide and included "char __infoc;"
When I changed that to a type int, the generated code is much better.
So the compiler is seeing the type cast but remembering that the
original type is char. It is also apparently assuming that the alignment
will be completely random so generates code assuming misalignment.
Easily fixed in my case but still very surprising.