home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / amiga / programm / 12548 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  2.0 KB

  1. Path: sparky!uunet!gatech!rutgers!cbmvax!jesup
  2. From: jesup@cbmvax.commodore.com (Randell Jesup)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Passing arguments to a process
  5. Message-ID: <34560@cbmvax.commodore.com>
  6. Date: 21 Aug 92 21:32:36 GMT
  7. References: <14kpbcINNfkn@darkstar.UCSC.EDU>
  8. Reply-To: jesup@cbmvax.commodore.com (Randell Jesup)
  9. Distribution: usa
  10. Organization: Commodore, West Chester, PA
  11. Lines: 46
  12.  
  13. torp@cats.ucsc.edu (Judith Lynn Nakamura) writes:
  14. >Using CreateNewProc(), how do I pass an argument (pointer or string)
  15. >to the new process?  I have tried
  16. >
  17. >strunct TagItem new_process_tags[] = {
  18. >    NP_Entry,    entry_point,
  19. >    NP_Arguments,    "argument"
  20. >    TAG_DONE
  21. >};
  22. >
  23. >but the function entry_point() does not recieve the string "argument".
  24.  
  25.     I suspect entry_point() is entry_point(char *foo), and is expecting
  26. the arguments on the stack.  What happens is that CreateNewProc() enters
  27. entry_point() with everything set up as if you had just started a program.
  28. Thus a0 will have a pointer to a copy of the string, and d0 will have the
  29. length.  In SAS, you would prototype the routine as:
  30.  
  31. LONG __asm __saveds
  32. entry_point (register __a0 char *args, register __d0 LONG arglen);
  33.  
  34. (__saveds is needed to set up A4 to point to any global data, needed unless
  35. you compile with -b0 and link with lcnb.lib).
  36.  
  37.     I prefer to use macros to make things readable/portable:
  38. #define ASM        __asm
  39. #define LOAD_A4        __saveds
  40. #define REG(x)        register __ ## x
  41.  
  42. (## is the ANSI token-pasting function).
  43.  
  44.     So that would become:
  45. LONG ASM LOAD_A4 entry_point (REG(a0) char *args, REG(d0) LONG arglen);
  46.  
  47. >Oh, BTW, why doesn't the 2.0 Libraries RKM discuss the dos.library?
  48.  
  49.     Dos is covered in the Bantam AmigaDos Manual, 3rd. Ed.  There are
  50. contractual reasons dating back to <1.0.
  51.  
  52. -- 
  53. "Rev on the redline, you're on your own; seems like a lifetime, but soon it's
  54.  gone..."  Foreigner
  55. -
  56. Randell Jesup, Jack-of-quite-a-few-trades, Commodore Engineering.
  57. {uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com  BIX: rjesup  
  58. Disclaimer: Nothing I say is anything other than my personal opinion.
  59.