[comp.sys.mac.programmer] CODE segments

ews00461@uxa.cso.uiuc.edu (11/10/89)

I find the discussion of segmentation very interesting, and I have a
few questions which are probably more basic...

Suppose I was going to write a compiler for the Mac.  My understanding of
what this beast should finally create is this:
	The output would perhaps be a file of type APPL with a number
of CODE segments (among a few other things).  The CODE segments themselves
are of interest to me.  Such CODE segments should contain completely
relocateable code.  All global variables should be reference from A5,
(where does A5 get set?).  All local variables should be on the stack.
All jumps should be relative, if they are in the same segment, and
should go through the jump table if they are to another segment (how is
this done, I assume there is a toolbox call to do this?)  There must
be at least 2 (?) segments, 1 jump and 1 with real code.

Any insight into this whole area would be very interesting.  And
obviously, there are a few people on this net for whom this is
trivial.  Any wisdom to pass on ?

Eric W Sink
ews00461@uxa.cso.uiuc.edu

d88-jwa@nada.kth.se (Jon Watte) (11/14/89)

In article <227700050@uxa.cso.uiuc.edu> ews00461@uxa.cso.uiuc.edu writes:

>I find the discussion of segmentation very interesting, and I have a
>few questions which are probably more basic...

I too am VERY interested in the inside of the CODE segments.
Unfortunately neither the TechNotes nor IM have very much to say
(other than you cannot have more than (4096-x, x== ?) jump table
entries. (The jump table entries contain code for loading a segment
and junmping. In EIGHT BYTES ? What code ?

>Suppose I was going to write a compiler for the Mac.  My understanding of
>what this beast should finally create is this:

>(where does A5 get set?).  All local variables should be on the stack.

>Any insight into this whole area would be very interesting.  And
>obviously, there are a few people on this net for whom this is
>trivial.  Any wisdom to pass on ?

PLEASE, do ! I've been pulling my hair but decided that "It's probably
of no use"... But now that other people as well have asked, my curiosity
is KILLING me !

Happy Hacking !
								h+

-- 
This .signature is longer than 4 lines. If you'd like to see it in whole,
please send a note to me. I'm h+@nada.kth.se and also h+@proxxi.se    8')

lim@iris.ucdavis.edu (Lloyd Lim) (11/14/89)

The Segment Loader chapter and the Memory Manager diagrams give a fairly
brief but adequate description of how everything works.  It does only take
8 bytes to load a segment!  (Thanks to a ROM call.)

+++
Lloyd Lim     Internet: lim@iris.ucdavis.edu (128.120.57.20)
              Compuserve: 72647,660
              US Mail: 146 Lysle Leach Hall, U.C. Davis, Davis, CA 95616

t-jlee@microsoft.UUCP (Johnny Lee) (11/15/89)

In article <5930@ucdavis.ucdavis.edu> lim@iris.ucdavis.edu (Lloyd Lim) writes:
>The Segment Loader chapter and the Memory Manager diagrams give a fairly
>brief but adequate description of how everything works.  It does only take
>8 bytes to load a segment!  (Thanks to a ROM call.)
>

I think the best reference for Mac programming I've read is
Scott Knaster's (spelling?) "How to write Macintosh software".
The book has got a very good description about memory management
including code segment unloading.

Johnny Lee
Standard Disclaimer.