What would be most advantageous when calling a function, put it in the stack from right to left or vice versa?
If I understand what you want to know, in your code, it usually makes little difference how you put it. It's interesting to worry about this just because of some optimization for some specific situation, after all you have call convention that put the first parameters directly into the recorder if possible.
We are talking about what architecture? It may vary. What can look good in one may not be the best in another. Even how it compiles can vary. In fact you are speaking of two languages and this will change as well. It may vary based on the API you are using.
Note that there is a difference between you writing your code and what the compiler will do. And what the compiler will do is a decision of it according to the standard convention or else if the code indicates this.
C usually used from right to left. Pascal usually uses left to right. But it's not your code problem unless you need to interoperate or need extreme optimization.
Note that the typical language convention need not necessarily be used in it, nor is it unique to it.
If you are not thinking about optimization, it does not matter how you put the arguments.
What about cleaning the battery? Should the caller or caller be responsible for this?
It depends on the convention used, it may be the responsibility of both, each one takes care of a part, which is the case of cdecl
, although strictly considered to be the caller who is responsible.
Much of the conventions let the calling function handle the preservation and cleanness of registers, including the pointer to the stack, which tends to make the code more efficient, with stdcall
.
When the calling function is responsible for cleaning the stack, it is possible to create functions with the amount of variable parameters
It's actually possible to have variable amount of arguments, not parameters .
It's something that I do not know or did not attack or understand the question, the rest seems correct.