[comp.sys.mac.programmer] Birth of A5 world ?

esink@turia.dit.upm.es (Eric Wayne Sink) (02/18/91)

	  How does the Finder launch programs ?  Who allocates the A5
	  world memory, the finder ?  How do global variables get
	  initialized under Think C, MPW ?  What kind of code do these
	  compilers insert in the application, which runs before
	  main() ?

          Lots of questions, I know.  If I understand right, Think C
	  places all the global data in a resource of type DATA, and
	  inserts some code which runs on startup to read that info
	  into A5 world.  But, does the application have to allocate
	  its own A5 world and then set A5 to point somewhere in it ?
          MPW has its %A5init thing - does that work similarly ?

	  Just curious...

Eric W. Sink                     | Putting the phrase      |All opinions
Departamento de Telematica       | "Frequently Asked"      |are mine and
Universidad Politecnica de Madrid| in your kill file is    |not necessarily
esink@turia.dit.upm.es           | not recommended.        |yours.

beard@ux5.lbl.gov (Patrick C Beard) (02/20/91)

In article <1991Feb18.133939.12001@dit.upm.es> esink@turia.dit.upm.es (Eric Wayne Sink) writes:
#
#	  How does the Finder launch programs ?  Who allocates the A5
#	  world memory, the finder ?  How do global variables get
#	  initialized under Think C, MPW ?  What kind of code do these
#	  compilers insert in the application, which runs before
#	  main() ?
#

In my experience, the segment loader allocates the A5 world for an application,
loads the jump table into it, and calls the application's first jump table
entry.  That's all the operating system does for an application.  It is the
development system's run-time library that initializes the application's
globals.  In THINK C, the DATA resource stores the values for the application's
globals, while under MPW %A5Init stores the globals in a compressed format
which it decompresses as it initializes the globals.

--
------------------------------------------------------------------
|  Patrick C. Beard, Software Engineer, Berkeley Systems, Inc.   |
|                    "Heroes of technology."                     |
|    beard@lbl.gov, d0346@applelink.apple.com (ATTN: Patrick)    |