[comp.sys.apple] large GS programs in APW C

AWCTTYPA@UIAMVS.BITNET ("David A. Lyons") (03/21/89)

>Date:         Mon, 20 Mar 89 07:15:17 GMT
>From:         Scott Lindsey <claris!wombat@APPLE.COM>

About APW C (and/or MPW IIgs C?):

>You CAN have a program larger than a bank (remember my rogue-clone
>port?  [still being debugged]).  What you're basically limited to is
>1 bank (64K) of data.  The equivalent of _main() sets the data bank
>to the bank containing your data (singular) segment. [...] Now, you
>say, who on earth would want more than 64K of data?  How 'bout a
>program that needs 1.25Mb to run?

The 64K limit applies only to SIMPLE STATIC variables, right?  (Not
to arrays or to auto variables.)  I have a hard time imagining how
to use up all 64K.

Desktop programs like AWGS (or anything that lets you work with
multiple documents) doesn't need much global data anyway--just
allocate whatever you need from the memory manager when it's needed.

Does something come out of that 64K that I'm forgetting?

>Scott Lindsey
>Claris Corp.
>ames!claris!wombat
>wombat@claris.com

wombat@claris.com (Scott Lindsey) (03/21/89)

From article <8903201806.aa11426@SMOKE.BRL.MIL>, by AWCTTYPA@UIAMVS.BITNET ("David A. Lyons"):

> About APW C (and/or MPW IIgs C?):
> 

> The 64K limit applies only to SIMPLE STATIC variables, right?  (Not
> to arrays or to auto variables.)  I have a hard time imagining how
> to use up all 64K.
OK, arrays go into ~arrays.  Locals are allocated on the direct page.
Any other variables are in ~globals (globals, static globals & static locals).
I assume APW C is this way as well (I've forgone it for MPWIIGS C).  
 
> Desktop programs like AWGS (or anything that lets you work with
> multiple documents) doesn't need much global data anyway--just
> allocate whatever you need from the memory manager when it's needed.

I really wasn't referring directly to AWGS...
I don't know how much non-dynamic space AWGS uses (static is a poor term
here, because it means something different to C than it does to the loader),
especially if you add up the 6 modules and all the internal stuff.  What's
really bad is that the 6 modules are all (mostly) dynamic.  If it were done
in C using the 1 data bank scheme, all the non-array variables for every
module, loaded or not, would have to be loaded all the time.  Yes, you can
start using a multi-bank scheme, but that's where it starts getting messy,
especially if you mix in assembly code.

 
> Does something come out of that 64K that I'm forgetting?

Initialized variables, maybe?  The only thing that goes in ~arrays are
arrays.  I assume by auto variables you mean auto-initialized variables?
They go right in ~globals too.

Don't get me entirely wrong.  C is my choice of languages to program in.
C for the GS, though, does not lend itself to major applications.  You
have to be intimately familiar with the architecture, and you have to
mix assembly or use it inline.  BTW, there is code you cannot generate
using inline assembly, (such as self-modifying code - which does have its
uses sometimes).

If I were to start developing a program for the GS right now, I'd use a mix
of C, inline assembly, and assembly, but still not be entirely happy.  For
anyone not familiar with the GS and 65816, my advice is to start in assembly,
learn it well, then use C later on when you know how to mix and match the
two.  I am not very familiar with the Pascal for the GS.  I much prefer
C over Pascal, incidentally, but I seem to recall that GS Pascal generates
generally more efficient code that C does.



-- 
Scott Lindsey     |"Cold and misty morning. I heard a warning borne in the air
Claris Corp.      |    About an age of power when no one had an hour to spare"
ames!claris!wombat| DISCLAIMER: These are not the opinions of Claris, Apple,
wombat@claris.com |    StyleWare, the author, or anyone else living or dead.

gwyn@smoke.BRL.MIL (Doug Gwyn ) (03/22/89)

In article <8903201806.aa11426@SMOKE.BRL.MIL> AWCTTYPA@UIAMVS.BITNET ("David A. Lyons") writes:
>The 64K limit applies only to SIMPLE STATIC variables, right?  (Not
>to arrays or to auto variables.)  I have a hard time imagining how
>to use up all 64K.

I think earlier (Beta test) versions of APW C had a 64K restriction on
all data, not just nonaggregates.  APW C 1.0 (final version) does claim
to support large arrays.

I think autos are allocated off the "stack", which even with various
forms of kludgery (2/CSTART replacement) cannot exceed 64Kbytes.
Many so-called "real" computers like Gould PowerNodes have a similar
problem.  When designing code that might be used in such a small-stack
environment, it is important to assign larger objects to static storage
duration (in which case APW C and some IBM PC compilers may still have
problems) or to dynamically allocate them