8K limit on arrays.
David Williams (davidwilliams@ozemail.com.au)
Tue, 9 Nov 1999 12:42:44 +1100
Thanks for responses Alan,
see my comments below
At 10:35 AM +1100 11/9/99, David Williams wrote:
>Hi all,
>
>A while ago I posted a query about 8K limit on arrays in GCC. Anyway it
>turns out the problem is related to -mshort option. When not using this
>option (which makes integers 16 bit by default) the problem disappers.
With 16 bit arithmetic, the biggest calculated displacement on
an array is 16 bits (that's -32k..32k). Divide that by
4 gives an 8k limit on long and float arrays. doubles would
be even smaller.
More specifically the problem with that the array (no matter what type)
could not exceed 8K bytes. That is an array of 16 bit ints could not be
bigger than 4095! I discovered the problem with an array of structures (10
bytes per structure) that could not exceed 818 elements!
>I also noticed that the code size generated goes down, not up as I
>expected. Can anyone explain this.
The 68k has variable-length addressing modes. Without -mshort,
it can have 32bit displacements added to an object. That makes
the instructions significantly longer.
Depending on the code you are compiling, these longer instructions
may not be more efficient.
I should have been more specific here, the total code size when using
-mshort is actually larger, than when not using
-mshort. This seems to be the opposite of what I would expect.
Dave.
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com