[Scummvm-devel] Wii & Gamecube (resp. PowerPC) vs. unaligned memory access

Andre Heider a.heider at gmail.com
Thu May 5 19:04:20 CEST 2011


On Thu, May 5, 2011 at 3:08 PM, Max Horn <max at quendi.de> wrote:
> Hi Andre, hi all
>
> I was wondering why we set need_memalign=yes for the Wii and Gamecube ports in ScummVM's configure script.
>
> So far, I thought that PowerPC and x86 are the two archs where unaligned memory access is handled in a relatively decent way -- of course still slower than aligned access, but otherwise fine (in particular, the CPU handles it natively, no OS fault handler or anything like that is involved). The bit on PowerPC I still know from past Mac development work; and various sources on the net seem to confirm it, e.g. <http://www.ibm.com/developerworks/library/pa-dalign/> or some Linux kernel developers <http://lwn.net/Articles/277201/>. Also, Hubert just confirmed that unaligned access seems to work fine on his PowerPC AmigaOS machine
>
> Is the PowerPC processor used in Gamecube and Wii different / crippled in this regard?
>
>
> Cheers,
> Max

Hi,

ugh, it's been a while, but as far as I remember not every powerpc is
capable of that. Accessing unaligned addresses on a 750CL using >8bit
instructions that cross a 64bit boundary shouldn't work. Maybe with a
fault handler that acts on alignment exceptions and splits the access.
Anyway, the broadway on the Wii requires alignment on certain
instructions, and I think I added need_memalign because I ran into the
issue. Maybe just with -fstrict-aliasing (which is implied by >= -O2),
but I really can't remember. Also, we run on bare metal there and the
hardware exception handler of the homebrew libs halts in the case of
an alignment exceptions.

And, coming from an apple user, hearing about a powerpc being crippled
compared to x86 is new. Others would choose the words "less insane" :)

Regards,
Andre




More information about the Scummvm-devel mailing list