On Wed, Jul 31, 2002, Muli Ben-Yehuda wrote about "Re: GNU Assembler #2":
> many arguments, through a function pointer. Here's code that does it,
> doing in asm only the required bits:
> 
> #include <stdio.h>
> 
> typedef void (*pfunc)(void); 
> 
> void caller2(void* pfn, unsigned long* params, unsigned int nargs)
> {
>       pfunc func = (pfunc)pfn; 
> 
>       while (nargs--) 
>               asm ("pushl %0" ::"g" (params[nargs]));
> 
>       (*func)(); 
> }

What is this "pushl" assembly instruction? Can't you put things on the
stack with a normal "movl"? (see, I told you my assembly is very rusty...)

Can't something like this work? (I'm assuming the stack in i386 goes
up. I'm *really* rusty in assembly, so I am probably botching this up.
I also have no idea how large is each frame on the stack, I added 2
just as an example)).

 void caller2(void* pfn, unsigned long* params, unsigned int nargs)
 {
        /* WARNING: this is very unportable! (if works at all :) ) */
        while (nargs--) 
                ((long *)&nargs)[nargs+2]=params[nargs];
 
        (*(pfunc)pfn)(); 
 }

-- 
Nadav Har'El                        |       Wednesday, Jul 31 2002, 22 Av 5762
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Cigarette: tobacco wrapped in paper, fire
http://nadav.harel.org.il           |at one end, and a fool at the other.

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to