Path: utzoo!attcan!uunet!mcsun!unido!rwthinf!truth!krischan From: krischan@truth.informatik.rwth-aachen.de (Christian Engel) Newsgroups: comp.os.os9 Subject: Re: Passing parameters by registers is bad use?!?!? Keywords: C compiler, parameter passing Message-ID: <3552@rwthinf.UUCP> Date: 30 Sep 90 13:13:40 GMT References: <3537@rwthinf.UUCP> <2820@cernvax.UUCP> <3117@mcrware.UUCP> Sender: news@rwthinf.UUCP Reply-To: krischan@truth.UUCP (Christian Engel) Organization: Informatik RWTH Aachen Lines: 46 In article <2820@cernvax.UUCP> rbt@cernvax.UUCP (roberto divia) writes: >1) the stack push/pop/stackPointerRearrangement takes time; In article <3117@mcrware.UUCP> kim@mcrware.UUCP (Kim Kempf) writes: >The OS-9 C code in assembler. Notice the 2-byte argument loads and >the absence of the stack cleanup after the function call. > [...] >Which is smaller and faster! Allright, I've got it. But You missed to tell me how about the *called* function! However I think I've got the explanation: Sometines you need an additional move operation saving the parameters passed via d0/d1. This saving is done by the movem operation at the beginning of every function entry which also saves all registers used for local variables of storage class register. If and only if you pass parameters and there are no register variables inside the function the movem is required only for the d0/d1 saving. In this case you loose a little time and code compared with the parameter passing via stack. I haven't made my mind up what comes up at the end if you compare both models of parameter passing, but after considering Your answers and the explanations above I think statistically the passing via registers will win clearly. Am I right? In article <2820@cernvax.UUCP> rbt@cernvax.UUCP (roberto divia) writes: >2) bigger is the data area used by the code is and easier is to have a > cache miss (this in case of processors with data caches). Now, that's too high for me. Why should the chance of cache miss increase in passing parameters via stack? The first two parameters need space in the stack frame of the called function anyway. That means there is no difference! The only difference is, that passing parameters via stack moves them into the stack frame *before* entering the called function (done by the caller) and passing parameters via registers d0/d1 moves them into the stack frame after entering the called function (done by the callee). krischan -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- krischan@informatik.rwth-aachen.de *** mcvax!unido!rwthinf!strange!krischan Christian Engel, Lehrstuhl fuer Informatik I, RWTH Aachen Ahornstr. 55, D-5100 Aachen, W. Germany