cleaning stack after a fn call
[snip]
Quote:
> I did. Caller didn't clean. Is my C++ compiler defective?
No, not defective. As I said, it may depend on the
vendor. They may even be passing parms in registers,
which is another way of doing things.
Quote:
> Actually the caller-cleans can be faster because arguments can be reused, and
> also you can clean up several function calls in one operation, thus amortizing
> some of the cost.
This is incorrect. If it's caller cleans, then EVERYWHERE there is a
function call, there is parameter set up, the call, then clean up.
This'll be for every function call. If you have a particular function
that is being called from 100 different locations in your source files,
then you'll have 100 setups, calls, then clean ups.
If it's called-cleans, then the function being called cleans up after
itself IN JUST ONE PLACE. It's easy realize the difference; you should,
although, use a "significant" size application to see the dramatic
decrease in size, speed. You might not see anything with a "hello world"
application.
Quote:
> But what does this have to do with C++ or Pascal? There is no such thing
> as ``Pascal'' calling conventions or C calling conventions. Neither of
> these languages define such conventions.
Actually, you're incorrect here again. Ask any developer that has been
involved in this respect; going back, say 10 years. This was a
commonplace thing to do. There IS a Pascal calling convention and there
IS a "C" calling convention ("C" compilers will discuss this subject
matter in great detail). This is because Pascal sets up, calls, and
cleans up in a different manner than "C" does. This is why "C" can offer
variable length argment lists.
The "other" convention is known as the "register" calling convention.
This is where the arguments, where applicable, are passed in registers.
Watcom was (if I remember correctly) the first to introduce this. Alot of
compilers these days use this style because it's faster and cheaper.
I dont have the K&R book here with me, but I think I remember them
discussing the "C" convention.
--
##################################
#Blue Skies! #
#remove "no-spam-" when replying.#
##################################