home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22091 < prev    next >
Encoding:
Text File  |  1993-01-24  |  1.7 KB  |  44 lines

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