GCC produces code with Unaligned Address Error on m68k when defining a local string

165 Views Asked by At

I am declaring a string that is 5 bytes long (including the null terminator) in a function:

int main(){ 
    char fstring[] = "AAAA";
    ...

Which generates the following asm code:

main:
link.w %fp,#-16
move.l #1094795585,-13(%fp)
clr.b -9(%fp)
...

move.l or move.w to an odd address causes an Address Error exception on 68k. Is there anyway to force the compiler to emit correct code?

1

There are 1 best solutions below

0
puppydrum64 On

Since you're compiling for the original 68000, this is definitely a bug. Writing a word or longword to an odd memory address is always an alignment fault and the compiler should be smart enough to know this.