home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!data.nas.nasa.gov!taligent!kip-50.taligent.com!user
- From: keith@taligent.com (Keith Rollin)
- Subject: Re: help calling assembly from C
- Message-ID: <keith-240193173019@kip-50.taligent.com>
- Followup-To: comp.sys.mac.programmer
- Sender: usenet@taligent.com (More Bytes Than You Can Read)
- Organization: Taligent
- References: <2B6198C1.22487@news.service.uci.edu>
- Distribution: usa
- Date: Mon, 25 Jan 1993 01:34:42 GMT
- Lines: 30
-
- In article <2B6198C1.22487@news.service.uci.edu>, eapg070@orion.oac.uci.edu
- (Caroll Elke Pohl) wrote:
- >
- > i wonder if someone out there can assist me with a small problem.
- > i'm using MPW (3.2) and want to call an assembly language subroutine
- > i wrote from a C program _however_ i want to pass the parameters in
- > A0 and A1 instead of using the stack (much like certain memory
- > manager traps). how can i get the C compiler to recognize this fact?
-
- You came really close to answering your own question. You know that there
- are Mac OS functions that work like this, so why don't you declare your
- function the same way they are? For instance:
-
- #pragma parameter DisposePtr(__A0)
- pascal void DisposePtr(Ptr p);
-
- This is an example of a function that simply takes a parameter in A0.
- Here's a more complex example:
-
- #pragma parameter __D0 HoldMemory(__A0,__A1)
- pascal OSErr HoldMemory(void *address,unsigned long count);
-
- HoldMemory takes the first parameter ("address") in A0, and the second
- parameter ("count") in A1. It returns its result in D0 (which will be
- treated like a short, because the function is declared to return an OSErr).
-
- -----
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-