[MPlayer-dev-eng] silly code

Artur Skawina skawina at geocities.com
Thu Jan 3 09:07:34 CET 2002


Arpi wrote:
> 
> But there are a few function which uses registers for parameters, instead of
> stack like C does.
> And I need ideas how to modify above wrapper to keep the value of
> registers, and pass them to the called orig function, and the same for
> returned values.
> 
> I think something like this:
> 
> void fake_func(){
>         asm { ... save registers to memory ... }
>         printf( ... );  // from memory
>         restore regs, call orig func, save regs again
>         printf  retrun values
>         restore regs, ret
> }

won't work.

> problem: it seems to gcc compiles extra code to modify EBP etc before the
> asm {} block begins, so it will save already modified valiables.
> 
> maybe the whole fake_fucn should be written in pure asm, and it should call
> another c function for printf job?

yes, either an asm wrapper, or make your fake function use a similar
calling convention (eg via gcc function attributes and/or flags).




More information about the MPlayer-dev-eng mailing list