Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ncar!zaphod.mps.ohio-state.edu!ceres.physics.uiowa.edu!news.iastate.edu!sharkey!umich!umeecs!msi.umn.edu!cs.umn.edu!kksys!edgar!mmug!p510.f22.n282.z1.mmug.edgar.mn.org!Jim.Spencer From: Jim.Spencer@p510.f22.n282.z1.mmug.edgar.mn.org (Jim Spencer) Newsgroups: comp.sys.mac.programmer Subject: How to interpret CODE 0? Message-ID: <2.27ACFB12@mmug.edgar.mn.org> Date: 4 Feb 91 05:39:08 GMT Sender: ufgate@mmug.edgar.mn.org (newsout1.26) Organization: FidoNet node 1:282/22.510 - SmorgasBoard UUCP, Twin Cities, MN USA Lines: 36 calvin@portia.stanford.edu writes in a message to All C> I have what may be a simple question, but then again I have C> not seen the answer documented anywhere. I read that CODE resource C> 0 acts as a map of all of the other CODE resources in an application, C> but how does one interpret this mapping? Is there somewhere that C> this is documented? See the Segment Loader Chapter of Inside Mac Vol. II which fully documents this. CODE 0 contains: 4 bytes: Above A5 size for the application (size in bytes from A5 to upper end of the application space. For applications this will be 32 bytes plus the jump table size. 4 bytes: Below A5; size in bytes of application globals plus QuickDraw globals 4 bytes: Length of jump table. 4 bytes: Offset to jump table from A5; 32 bytes for applications n bytes: Jump Table The jump table, which is loaded on application launch, consists of an entry for each routine that is referenced from another segment: 2 bytes: offset of routine from beginning of its segment 4 bytes: instruction for moving the segment number for this routine onto the stack. 2 bytes: LoadSeg trap. When the program starts up, the jump table is loaded and then the first entry in the jump table is executed. This normally loads segment 1 (CODE 1) and jumps to the main entry point. Other than tracking this one entry, tracing the other jump table entries is a truly boring, useless thing to do. -- Jim Spencer - via The Minnesota Macintosh Users Group UUCP-Fido Gateway UUCP: ...uunet!tcnet!kksys!edgar!mmug!22.510!Jim.Spencer INET: Jim.Spencer@p510.f22.n282.z1.mmug.edgar.mn.org