[MPlayer-dev-eng] OT: loader/stubs.s:EH_prolog convertion to C

Alex Beregszaszi alex at naxine.org
Wed Oct 23 20:47:18 CEST 2002


Hi,

i've converted it into C using gcc __asm__, but I got some questions:

original function:
EH_prolog:
	pushl $0xff
	pushl %eax
	pushl %fs:0
	movl %esp, %fs:0
	movl 12(%esp), %eax
	movl %ebp, 12(%esp)
	leal 12(%esp), %ebp
	pushl %eax
	ret

c function:
void exp_EH_prolog(void)
{
__asm__ __volatile__(
	"popl %%ebp		\n\t"
	"pushl $0xff		\n\t"
	"pushl %%eax		\n\t"
	"pushl %%fs:0		\n\t"
	"movl %%esp, %%fs:0	\n\t"
	"movl 12(%%esp), %%eax	\n\t"
	"movl %%ebp, 12(%%esp)	\n\t"
	"leal 12(%%esp), %%ebp	\n\t"
	"pushl %%eax		\n\t"
	: : : "esp", "ebp");
return;
}

thats not working, so i disassembled the objects: gcc is putting its own function-frame codes
(altought my functions isn't defining any parameters) (note: i removed "esp", "ebp", but no sense)

pushl	%ebp
mov	%esp, %ebp
... (my code)
mov	%ebp, %esp
pop	%ebp
ret

so i did a hack, and it's now working:
pushl	%ebp
mov	%esp, %ebp

popl	%ebp
... (my code) + ret
mov	%ebp, %esp
pop	%ebp
ret

It's working for me (tm). Are there any better solutions?

-- 
Alex Beregszaszi  <alex at naxine.org>



More information about the MPlayer-dev-eng mailing list