3 ms·
> On ARM we’d also run into alignment issues... Just don't use ARMv5 or older. ARMv6+ supports unaligned access.
by vardump 7y ago
> On ARM we’d also run into alignment issues...
Just don't use ARMv5 or older. ARMv6+ supports unaligned access.
- planteen 7y agoAt least on ARMv7, it's up to the MMU, not the CPU. I've worked with Cortex-A9s that trap the unaligned access. You can write a handler or crash.
- vardump 7y agoInteresting. I've kept my accesses aligned, but noticed that unaligned ones worked. Didn't know about the exception mechanism behind, but yeah, should have err... expected it. By the way, you can also opt to crash on x86. Just need to enable bit AM (Alignment Mask) bit 18) in CR0 (kernel stuff) and AC (Alignment Check, also bit 18) in EFLAGS. After that point, unaligned accesses trap. I use this in my CPU JIT/dynamic compiler to trap target unaligned accesses. https://en.wikipedia.org/wiki/Control_register#CR0 https://en.wikipedia.org/wiki/Control_register#CR0