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

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!news.ccs.queensu.ca!slip202.telnet1.QueensU.CA!dmurdoch
  3. From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
  4. Subject: Re: Calling convention: C vs PASCAL
  5. Message-ID: <dmurdoch.231.724340705@mast.queensu.ca>
  6. Lines: 22
  7. Sender: news@knot.ccs.queensu.ca (Netnews control)
  8. Organization: Queen's University
  9. References: <1992Dec11.225015.26304@eng.ufl.edu> <dmurdoch.225.724125846@mast.queensu.ca> <1992Dec14.124529@cs.utwente.nl>
  10. Date: Mon, 14 Dec 1992 13:45:05 GMT
  11.  
  12. In article <1992Dec14.124529@cs.utwente.nl> fijma@cs.utwente.nl (Duco Fijma) writes:
  13. >|> it's up to the called routine.  It's this difference that gives the Pascal 
  14. >|> convention the edge:  every time you call a C-convention routine you need to 
  15. >|> fix up the stack afterward, while a Pascal-convention routine does 
  16. >|> it in just one place.  On a PC, there's even a special form of RET to 
  17. >|> support the Pascal convention.  
  18. >
  19. >Waht difference does this make for execution time? The cleanup code has to be
  20. >executed for every invocation, whether it is included with the callers or the
  21. >called code. Of course it does make difference for the code size.
  22.  
  23. A Pascal routine with 20 bytes of parameters can return and clean up with 
  24. the single instruction:
  25.  
  26.      retf 20
  27.  
  28. On all 80x86 cpus, this takes the same time (plus or minus a cycle) as the 
  29. plain retf.  The advantage comes because that's all that's needed; a return 
  30. from a C convention routine must be followed by manual adjustment of 
  31. the stack pointer.
  32.  
  33. Duncan Murdoch
  34.