[comp.sys.mac] 32K barrier on the Mac...

reece@enuxha.eas.asu.edu (Glen A. Reece) (06/03/90)

Greetings again from AZ:

   I was having a discussion the other day with a friend who asked about
writing applications for the Mac.  I told him that the limitation to
application size was not memory but the 32K static data barrier that exists
on the Mac (64K on the PC I think).  Anyway, can someone please give a
good explanation of the reason for the 32K limit and reason as to why Apple
has not eliminated this constraint.

  Please respond to me directly, and if others are interested then I'll
post the responses back to comp.sys.mac

  Thankx in advance,

     - Glen A. Reece
       Industrial Fellow
       Artificial Intelligence Lab.
       Arizona State University

doner@henri.ucsb.edu (John Doner) (06/04/90)

In article <894@enuxha.eas.asu.edu> reece@enuxha.eas.asu.edu (Glen A. Reece) writes:
>Greetings again from AZ:
>
>   I was having a discussion the other day with a friend who asked about
>writing applications for the Mac.  I told him that the limitation to
>application size was not memory but the 32K static data barrier that exists
>on the Mac (64K on the PC I think).  Anyway, can someone please give a
>good explanation of the reason for the 32K limit and reason as to why Apple
>has not eliminated this constraint.
>
There is no 32K barrier; i.e., there is nothing intrinsic to the Macintosh
or its operating system which leads to such a limitation.  Nevertheless, one
does encounter it, so your puzzlement is justified.

The Motorola 68000 series chips have several addressing options for
their instructions, for example the branching instructions have forms
with 8 or 16 bit displacements from the current value of the program
counter, or a full 32 bit address.  Data references allow for similar
variations.  The shorter forms reduce code size, and were especially
important at a time when memory was more expensive than it is today.

As a result, many compilers gave 16-bit integers a special role, and
used them for array subscripts.  This leads to a 32K limitation on the
array size.  Apple designed its jump tables with 16 bit displacements
from the beginnings of code segments, so externally referenced
routines must appear in the first 32K bytes of a code segment.  Within
the segments, the 16-bit offset branching instructions are used, thus
limiting segment size to a practical maximum of 32K.

For the most part, these limitations are compiler-dependent, and
disappear when the compiler designers work to eliminate them.  (The
jump table limitation isn't just a matter of generating different
instructions, but it too can be overcome.)  Language Systems Fortran
and Absoft Fortran are two examples of compilers without 32K limitations.

Since Apple doesn't control the compiler writers, and there is a need
to maintain compatability with earlier products, they are limited in
what they can do to get away from 32K limitations.  They are clearly
headed in that direction.
-----------
John E. Doner	       | "The beginner...should not be discouraged if...he
Mathematics, UCSB      | finds that he does not have the prerequisites for
Santa Barbara, CA 93106| reading the prerequisites."
doner@henri.ucsb.edu   |      --Paul Halmos, Measure Theory