home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.msdos.programmer
- 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
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Subject: Re: Calling convention: C vs PASCAL
- Message-ID: <dmurdoch.231.724340705@mast.queensu.ca>
- Lines: 22
- Sender: news@knot.ccs.queensu.ca (Netnews control)
- Organization: Queen's University
- References: <1992Dec11.225015.26304@eng.ufl.edu> <dmurdoch.225.724125846@mast.queensu.ca> <1992Dec14.124529@cs.utwente.nl>
- Date: Mon, 14 Dec 1992 13:45:05 GMT
-
- In article <1992Dec14.124529@cs.utwente.nl> fijma@cs.utwente.nl (Duco Fijma) writes:
- >|> it's up to the called routine. It's this difference that gives the Pascal
- >|> convention the edge: every time you call a C-convention routine you need to
- >|> fix up the stack afterward, while a Pascal-convention routine does
- >|> it in just one place. On a PC, there's even a special form of RET to
- >|> support the Pascal convention.
- >
- >Waht difference does this make for execution time? The cleanup code has to be
- >executed for every invocation, whether it is included with the callers or the
- >called code. Of course it does make difference for the code size.
-
- A Pascal routine with 20 bytes of parameters can return and clean up with
- the single instruction:
-
- retf 20
-
- On all 80x86 cpus, this takes the same time (plus or minus a cycle) as the
- plain retf. The advantage comes because that's all that's needed; a return
- from a C convention routine must be followed by manual adjustment of
- the stack pointer.
-
- Duncan Murdoch
-