On Wed, Jul 31, 2002 at 05:08:05PM +0300, Alexander V. Karelin wrote:
> Hmm..... Hmmm........
> 
> Well, the problem with the first idea is that pushing stuff into stack
> directly from C code is not really worthy because a simple call to "while"
> may cause things to be pushed and popped around, which will break the
> continium and.... Well - the parameters will be either removed or replaced
> in the stack.

Wrong. If you do it properly via inline ASM, you're guaranteed that
the compiler won't interfere. You have to give it the proper
constraint. 

> As for the trick with going into stack addresses through C - it is doable,
> but it is:
> 
> 1. Illegal

You mean "non portable". 

> 2. May cause exceptions in some cases

Kindly elaborate?

> 3. Is surely a bad idea for anything that has to run as a daemon or as a
> server.

Is a bad idea in general. But then again, so is the entire idea of
calling a function in the way you want to, unless you have a very good
reason. Type safety and the rest of the things the compiler checks are
a heavy price to pay unless you have a very good reason. 

> As for the optimization suggestion of reducing the nArgs by one each time
> - the suggestion is great, but my "assembler" thinking isn't good enough
> yet to implement that, without doing something wrong:)))) (The new version
> is on its way...)
> 
> Anyhow, there are two additional "minor" issues:
> 
> 1. The return code from the call (if any). Very tricky point, considering.
> But it seems less complicated as it is one return value per call, and not
> a variable length list of thingies.

What's tricky about it? IIRC, you just put the retval in eax and be
done with it. 

> 2. The "nArgs" has (I presume) to be replaced by an array of unsigned ints
> that will specify the size of each corresponding argument. Since we may
> have char and short type parameters, it is important that the code is
> aware of the parameters size when pushing 'em into the stack.

That's true. Of course, you could take a shortcut and always pass
*ONE* argument, which is the address of a structure that has all of
the other arguments, with corresponding types and sizes. Again, why do
you want to do this?

> Back to the safety of my c++ world that polymorphs the troubles of
> assembler into an endless stream of useless instructions nobody wishes to
> read...:))) Thank You.

Sure, it's been an amusing excersize. 
-- 
http://vipe.technion.ac.il/~mulix/
http://syscalltrack.sf.net/

Attachment: msg20807/pgp00000.pgp
Description: PGP signature

Reply via email to