[comp.sys.mac.programmer] Segmentation in Mac ?

meric@portia.Stanford.EDU (meric ozcan) (06/29/90)

Hi,
I have a question, could someone please explain? 
I was looking at the Think C manual and there was this line (I am not a Mac
programmer):
The static and global data area of Think C applications is limited to
32K total per project. If you want to be able to access global or local
memory larger than the 32K limit, allocate the memory dynamically as a
pointer or handle.
NOW: Is this the limitation of the compiler or the Mac? If it is not because
of the compiler why Mac people making fun of IBM people because of the 
segmentation problems in IBM? It is at least 64K in the IBM. 
I am just curious, any information is appreciated.
Thanks.
meric@portia.stanford.edu

chewy@apple.com (Paul Snively) (06/30/90)

In article <1990Jun29.025415.9897@portia.Stanford.EDU> 
meric@portia.Stanford.EDU (meric ozcan) writes:
> The static and global data area of Think C applications is limited to
> 32K total per project. If you want to be able to access global or local
> memory larger than the 32K limit, allocate the memory dynamically as a
> pointer or handle.
> NOW: Is this the limitation of the compiler or the Mac?

Both and neither.  It's a limitation of the way that the compiler 
generates code and in some respects a limitation of one particular 
addressing mode of the 68000.

On the Macintosh, application globals and the application jump table are 
both allocated relative to address register A5, and they are both accessed 
with the 68000's d(An) addressing mode, where "d" is some 16-bit offset.  
A signed 16-bit value can extend only 32K in either direction, for a total 
of 64K.

However, if you're willing to assume an '020 or better (or willing to use 
more than one instruction per access on a 68000), you can break the 32K 
global data barrier.  With a little more effort, you can also have code 
segments larger than 32K.  Actually, you've been able to do this for a 
while now, but your entry points have always had to be within 32K of the 
beginning of the segment.

I don't know about the THINK products, but MPW 3.2 will be "32-bit 
everything," eliminating the 16-bit limitations.

> If it is not because
> of the compiler why Mac people making fun of IBM people because of the 
> segmentation problems in IBM? It is at least 64K in the IBM.

The difference is that segmentation is an intrinsic part of the IBM's 
microprocessor, leading to nonsensical things such as near and far 
pointers in their C compilers and the like (to say nothing of the various 
"memory models"--small, medium, large, huge, gargantuan, et al.)  The Mac, 
thank God for small favors, has no such weirdnesses (it makes up for it 
with other ones).

__________________________________________________________________________
                                Paul Snively
                      Macintosh Developer Technical Support
                             Apple Computer, Inc.

chewy@apple.com

Just because I work for Apple Computer, Inc. doesn't mean that I believe 
what they believe, or vice-versa.
__________________________________________________________________________