Subject: Re: Possible bug in arm32 strongarm optimisations.
To: Ignatios Souvatzis <is@beverly.kleinbus.org>
From: Richard Earnshaw <rearnsha@arm.com>
List: tech-toolchain
Date: 10/30/2000 11:41:02
> On Wed, Oct 25, 2000 at 09:25:06AM +0100, Chris Gilbert wrote:
> > > ldr r3, [r5, #6]
> > >    r3 <- [5476]    // (in)famous rotating
> > > mov r0, r3, lsr # 16
> > >    r0 <- [--54]    // with the `-' zero
> > 
> > What is this rotating thing?  I don't remember coming across it before.  Is 
> > it documented anywhere?
> 
> On older ARMs, if you fetch a misaligned longword, you get a rotated aligned
> longword instead. This can be used as above to simulate word fetches. Although
> it's not clear to me why one wouldn't fetch the unrotated longword and mask
> that instead. Maybe because on virtually all registe-to-register ALU operations,
> you get a shift or a rotate for free.
> 

It's a side-effect of the way byte-fetching was implemented on the very 
first ARM chips (a byte fetch needs to rotate the required byte into the 
bottom bits, and the final result is then zero-extended -- an unaligned 
word fetch just drops the zero-extension).

A lot of oddities became architecturally defined because of the way they 
were implemented on the first ARM chips -- many of these were tightened up 
over time, but this is one that has to stay for legacy reasons (though the 
MMU can normally be configured to fault unaligned word accesses these 
days).

Richard.