Groups | Search | Server Info | Login | Register
Groups > comp.arch.embedded > #32471
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: arm-gcc, Cortex-M0+, uint64_t and alignment |
| Date | 2026-01-20 22:32 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <10kos8h$1ivol$2@dont-email.me> (permalink) |
| References | <10kns7l$1733k$1@dont-email.me> <10ko98i$1bptj$1@dont-email.me> <10kob7m$qel$1@reader2.panix.com> <10koep6$1dlne$1@dont-email.me> <10kogeb$n48$1@reader2.panix.com> |
On 20/01/2026 19:10, Grant Edwards wrote: > On 2026-01-20, David Brown <david.brown@hesbynett.no> wrote: > >> Cortex M3 and bigger all handle misaligned accesses without problem >> (albeit possibly at a performance penalty). > > FWIW, the M3 can be configured to generate a fault on unaligned > accesses, so whether it works or not depends on your low-level init > code. I believe that unaligned-fault-enable feature is disabled by > default at reset. I did not know that. > Also, The M3 only supports non-world aligned > accesses for normal signle store/load instructions. LDM/STM and > LDRD/STRD will fault on non-word aligned access. > Yes. Of course, the LDM/STM are primarily used for pushing and popping registers on the stack, so you are always going to be aligned there. In the godbolt.org link I posted in a reply to Pozz, we can see that when the compiler knows the uint64_t is aligned at least to 4 bytes, it uses LDRD, but when it does not know that it is 4 bytes aligned, it uses two LDR instructions. (As an aside, I find it annoying that STRD can be interrupted in the middle - it means you don't have an atomic 64-bit store. LDRD can also be interrupted in the middle, but as it is restarted, it gives you a 64-bit atomic read.)
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar
arm-gcc, Cortex-M0+, uint64_t and alignment pozz <pozzugno@gmail.com> - 2026-01-20 13:26 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment David Brown <david.brown@hesbynett.no> - 2026-01-20 17:07 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment Grant Edwards <invalid@invalid.invalid> - 2026-01-20 16:41 +0000
Re: arm-gcc, Cortex-M0+, uint64_t and alignment pozz <pozzugno@gmail.com> - 2026-01-20 18:09 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment David Brown <david.brown@hesbynett.no> - 2026-01-20 18:44 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment pozz <pozzugno@gmail.com> - 2026-01-21 09:11 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment David Brown <david.brown@hesbynett.no> - 2026-01-21 10:02 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment pozz <pozzugno@gmail.com> - 2026-01-21 15:58 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment David Brown <david.brown@hesbynett.no> - 2026-01-21 17:13 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment pozz <pozzugno@gmail.com> - 2026-01-21 17:57 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment David Brown <david.brown@hesbynett.no> - 2026-01-22 10:03 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment Grant Edwards <invalid@invalid.invalid> - 2026-01-20 17:48 +0000
Re: arm-gcc, Cortex-M0+, uint64_t and alignment David Brown <david.brown@hesbynett.no> - 2026-01-20 18:41 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment Grant Edwards <invalid@invalid.invalid> - 2026-01-20 18:10 +0000
Re: arm-gcc, Cortex-M0+, uint64_t and alignment David Brown <david.brown@hesbynett.no> - 2026-01-20 22:32 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment Grant Edwards <invalid@invalid.invalid> - 2026-01-21 03:38 +0000
Re: arm-gcc, Cortex-M0+, uint64_t and alignment David Brown <david.brown@hesbynett.no> - 2026-01-21 08:54 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment pozz <pozzugno@gmail.com> - 2026-01-20 17:55 +0100
Re: arm-gcc, Cortex-M0+, uint64_t and alignment David Brown <david.brown@hesbynett.no> - 2026-01-20 22:24 +0100
csiph-web