home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / msdos / programm / 11374 < prev    next >
Encoding:
Text File  |  1992-12-14  |  2.1 KB  |  50 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!mcsun!sun4nl!utrcu1!infnews!infnews!fijma
  3. From: fijma@cs.utwente.nl (Duco Fijma)
  4. Subject: Re: Calling convention: C vs PASCAL
  5. Message-ID: <1992Dec14.124529@cs.utwente.nl>
  6. Sender: usenet@cs.utwente.nl
  7. Nntp-Posting-Host: utis143
  8. Organization: University of Twente, Dept. of Computer Science
  9. References: <1992Dec11.225015.26304@eng.ufl.edu> <dmurdoch.225.724125846@mast.queensu.ca>
  10. Date: Mon, 14 Dec 1992 11:45:29 GMT
  11. Lines: 37
  12.  
  13. In article <dmurdoch.225.724125846@mast.queensu.ca>, dmurdoch@mast.queensu.ca (Duncan Murdoch) writes:
  14. |> In article <1992Dec11.225015.26304@eng.ufl.edu> zzang@stat.ufl.edu (zzang) writes:
  15. |> >the C pushs the arg from right to left onto
  16. |> >the stack when calling a function.
  17. |> >the PASCAL pushs the args from left to right.
  18. |> >I was told that the C calling convention results
  19. |> >in larger as well as slower program.
  20. |> >(due to some cleanup work of the stack after call??)
  21. |> 
  22. |> I don't think the parameter order makes any difference to calling efficiency.
  23. |> 
  24. |> The important difference between standard C and Pascal calling conventions 
  25. |> is that in C, it's up to the caller to clean up the stack, while in Pascal 
  26. |> it's up to the called routine.  It's this difference that gives the Pascal 
  27. |> convention the edge:  every time you call a C-convention routine you need to 
  28. |> fix up the stack afterward, while a Pascal-convention routine does 
  29. |> it in just one place.  On a PC, there's even a special form of RET to 
  30. |> support the Pascal convention.  
  31.  
  32. Waht difference does this make for execution time? The cleanup code has to be
  33. executed for every invocation, whether it is included with the callers or the
  34. called code. Of course it does make difference for the code size.
  35.  
  36.  
  37. |> The advantage of the C convention is that it makes it easy to call routines 
  38. |> variable numbers of parameters.
  39. |> 
  40. |> Duncan Murdoch
  41. |> dmurdoch@mast.queensu.ca
  42.  
  43. --
  44.  
  45. Duco Fijma               tel. X31-53-893718
  46. University of Twente     fax. X31-53-893811 
  47. P.O. Box 217             internet: fijma@cs.utwente.nl
  48. 7500 AE  Enschede        
  49. The Netherlands          | No ugly pictures in this sig! |
  50.