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

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!cs.utexas.edu!torn!news.ccs.queensu.ca!slip201.telnet1.QueensU.CA!dmurdoch
  3. From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
  4. Subject: Re: Calling convention: C vs PASCAL
  5. Message-ID: <dmurdoch.225.724125846@mast.queensu.ca>
  6. Lines: 23
  7. Sender: news@knot.ccs.queensu.ca (Netnews control)
  8. Organization: Queen's University
  9. References: <1992Dec11.225015.26304@eng.ufl.edu>
  10. Date: Sat, 12 Dec 1992 02:04:07 GMT
  11.  
  12. In article <1992Dec11.225015.26304@eng.ufl.edu> zzang@stat.ufl.edu (zzang) writes:
  13. >the C pushs the arg from right to left onto
  14. >the stack when calling a function.
  15. >the PASCAL pushs the args from left to right.
  16. >I was told that the C calling convention results
  17. >in larger as well as slower program.
  18. >(due to some cleanup work of the stack after call??)
  19.  
  20. I don't think the parameter order makes any difference to calling efficiency.
  21.  
  22. The important difference between standard C and Pascal calling conventions 
  23. is that in C, it's up to the caller to clean up the stack, while in Pascal 
  24. it's up to the called routine.  It's this difference that gives the Pascal 
  25. convention the edge:  every time you call a C-convention routine you need to 
  26. fix up the stack afterward, while a Pascal-convention routine does 
  27. it in just one place.  On a PC, there's even a special form of RET to 
  28. support the Pascal convention.  
  29.  
  30. The advantage of the C convention is that it makes it easy to call routines 
  31. variable numbers of parameters.
  32.  
  33. Duncan Murdoch
  34. dmurdoch@mast.queensu.ca
  35.