Close

aligned access

A project log for YGREC32

because F-CPU, YASEP and YGREC8 are not enough and I want to get started with the FC1 but it's too ambitious yet.

yann-guidon-ygdesYann Guidon / YGDES 10/03/2025 at 16:000 Comments

Linus delivered again !

https://lkml.org/lkml/2025/10/1/1140

Many interesting points but let's focus on this one:

 - only do aligned memory accesses

   Bonus point for not even faulting,
   and just loading and storing
   garbage instead.

It's 2025.

Why would anybody perform an unaligned access ?

I mean by that : mis-aligning a variable. It's slow and inconvenient, particularly for out-of-page access. It still exists for packed data (the BMP headers....) and that's why there is the insert/extract (IE) unit. But mostly you want to avoid that and keep your code lean.

There is the case of getting a bogus/random pointer that forces loading garbage, and indeed this is caught by an exception (just check x LSB). But a decent language shouldn't let unchecked pointers strive. That's why my architectures have two levels:

A further mechanism can be added:

if a register read is performed on a data register where the address register has LSB set, it may trap.

This is quite easy to implement, though it might have to ripple through the pipeline...

However, in the case of #aStrA : Aligned Strings format with attributes , we want an unaligned pointer to work. Is it worth an additional opcode ?

Discussions