[comp.sys.mac] Code Segments > 32K

rs4u+@ANDREW.CMU.EDU.UUCP (05/29/87)

in <2068@emory.UUCP>, gatech!seismo!cmcl2!nyu-acf2.arpa!siritzky (Brian
Siritzky) writes:

	".   ...  All of these C compilers
. will only allow you a 32K code segment - for the whole program. In our
. case this was way too little.
. I have since tried the MPW C. It is better than the others for my problems,
. although it still has the 32k limitation (I'm told that this is a problem
. with the Mac OS!).
"

	This is partially true. You're allowed a maximum of 32K of executable
code per code segment, but that is *not* a 32K limit on total program size.
You can have as many segments as you needs, and every single
development system I've come across (TML Pascal, MPW, LSP, LSC) has
provision for you to create multiple segments. Usually, the linker will
tell you if a code segment is too big, and allow you to create
new ones (Lightspeed C and Lightspeed Pascal make it especially easy).

	As far as this limitation being a "problem" with the Mac OS, I
doubt it. It *is* a limit, but the 32K segment limit assists in
using memory efficiently -- unused code can be dynamically unloaded and
reloaded, with very little programmer intervention. (You have to call 
a routine to unload a segment, but loading is done automatically.)

If you really wanted to, you could write your own segment loaded, and
then have segments as big as you want.

		--Rich

Richard M. Siegel
R-Squared Development Systems
134 Horseshoe Drive
Williamsburg, Virginia 23185
(804) 229-2152 [After 6pm eastern time only]

Arpanet: rs4u@andrew.cmu.edu
Uucp: {your fave gateway}!seismo!andrew.cmu.edu!rs4u

Disclaimer? I don't even KNOW 'er!

rae@unicus.UUCP (Clith de T'nir a.k.a. Reid Ellis) (06/01/87)

In article <gUjLscy00UhTg480nL@andrew.cmu.edu> rs4u+@ANDREW.CMU.EDU (Richard Siegel) writes:
|in <2068@emory.UUCP>, gatech!seismo!cmcl2!nyu-acf2.arpa!siritzky (Brian
|Siritzky) writes:
|>   ...  All of these C compilers
|> will only allow you a 32K code segment - for the whole program. In our
|> case this was way too little.
|> I have since tried the MPW C. It is better than the others for my problems,
|> although it still has the 32k limitation (I'm told that this is a problem
|> with the Mac OS!).
|	This is partially true. You're allowed a maximum of 32K of executable
|code per code segment, but that is *not* a 32K limit on total program size.
|	As far as this limitation being a "problem" with the Mac OS, I
|doubt it. It *is* a limit, but ...
[...]
|If you really wanted to, you could write your own segment loaded, and
|then have segments as big as you want.
|		--Rich

  Is it not true that there is no limit to CODE segments?  The bug that limits
segments to 32k is in WriteResource, so only the compiler needs to worry
about it.  Am I right on this?
  With MPW, you can say 'Link -ss 100000 foo.o -o foo' and you'll be allowed
to have segments of up to 100,000 bytes in size.  This will definitely work
on new ROM machines, but MPW says:

	64k ROM note:	Caution!  Applications with segments
			greater then 32k in size may not load
			correctly on Macintoshes with 64k ROMs.

  Will someone please make this clear?  Will a 37k CODE segment work on
an old-ROM Macintosh?
						Reid
--
	"Hey!  You're not Ricky Ricardo, you're
	a cop!  And those are potatoes."
					"Huh?  Hey -- the kid's right!
					You're under arrest, Pal!  Whew,
					you sure saved the day, kid."

Reid Ellis, aka Clith de T'nir
		{seismo!mnetor, utzoo!yetti}!unicus!rae	(uucp)
		mnetor!unicus!rae@seismo.css.gov	(arpa)

wetter@tybalt.caltech.edu (Pierce T. Wetter) (06/06/87)

>
>  Is it not true that there is no limit to CODE segments?  The bug that limits
>segments to 32k is in WriteResource, so only the compiler needs to worry
>about it.  Am I right on this?
>  With MPW, you can say 'Link -ss 100000 foo.o -o foo' and you'll be allowed
>to have segments of up to 100,000 bytes in size.  This will definitely work
>on new ROM machines, but MPW says:
>
>	64k ROM note:	Caution!  Applications with segments
>			greater then 32k in size may not load
>			correctly on Macintoshes with 64k ROMs.
>
>  Will someone please make this clear?  Will a 37k CODE segment work on
>an old-ROM Macintosh?
>						Reid

    The bug is in getResource and has to do with using a bset instead of a btst.
Consequently if you have an odd multiple of 32K the GetResource call will toast
32K of your CODE. THere was a TechNote on this with a Patch as well.
  PIerce WEtter


	After his Ignoble Disgrace, Satan was being expelled from
Heaven.  As he passed through the Gates, he paused a moment in thought,
and turned to God and said, "A new creature called Man, I hear, is soon
to be created."
	"This is true," He replied.
	"He will need laws," said the Demon slyly.
	"What!  You, his appointed Enemy for all Time!  You ask for the
right to make his laws?"
	"Oh, no!" Satan replied, "I ask only that he be allowed to make
his own."
	It was so granted.
		-- Ambrose Bierce, "The Devil's Dictionary"

--------------------------------------------

wetter@tybalt.caltech.edu

--------------------------------------------