home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!mimsy!mojo.eng.umd.edu!russotto
- From: russotto@eng.umd.edu (Matthew T. Russotto)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Assembly with C question...
- Message-ID: <1992Dec16.023307.16156@eng.umd.edu>
- Date: 16 Dec 92 02:33:07 GMT
- References: <1992Dec12.232559.265@physc1.byu.edu> <1992Dec13.215351.129652@watson.ibm.com>
- Organization: Project GLUE, University of Maryland, College Park
- Lines: 55
-
- In article <1992Dec13.215351.129652@watson.ibm.com> arsouth@watson.ibm.com (Andrew R. Southwick) writes:
- >In <1992Dec12.232559.265@physc1.byu.edu> seth@physc1.byu.edu writes:
- >>Hi. I have a question about assembly language and C. Here is a snippet of
- >>C code, followed by the same thing disassembled.
- >>
- >>
- >>main()
- >>{
- >> Init();
- >> MakeMenus();
- >> MakeWindow();
- >> AddrsSet();
- >> MakeGrid();
- >>
- >>
- >>main:
- >>00000000 JSR $0000(A5)
- >>00000004 JSR $0000(A5)
- >>00000008 JSR $0000(A5)
- >>0000000C JSR $0000(A5)
- >>00000010 JSR $0000(A5)
- >>
- >>
- >[...]
- >
- >Is this code in memory (i.e. disassembled while running) or taken from an
- >ececuatable/code resource? Probably the latter.
-
- Actually, neither-- I missed the original post so I'll respond now.
- That code is before the link step. It is when the project is linked
- that the proper A5 offsets are put in.
-
- >What happens after the program is loaded is the segment loader (or some
- >toolbox manager) steps in and replaces all these $0000's with real offsets
- >from building the jump table. The jump table is located up in the A5 global
- >area, hence the A5. The reason they won't point directly into code is to
- >allow for multiple segments, and dynamic loading/unloading of them. The JSR's
- >above leap to a small set of commands that either leaps back into the heap, or
- >calls a routine to load in the segment & then execute, depending on whether
- >the segment is loaded or not. Some development environments will handle this
- >differently; as far as I know, both MPW and Think C both do it this way.
-
- Aside from the first bit-- its the linker which puts in the real
- offsets, not any toolbox manager-- this is correct.
-
- >[Man, I really miss a good text editor...]
-
- You would prefer Xedit? <evil grin>
-
-
- --
- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu
- Some news readers expect "Disclaimer:" here.
- Just say NO to police searches and seizures. Make them use force.
- (not responsible for bodily harm resulting from following above advice)
-