ao_pulse: support native mute control
[mplayer.git] / loader / wrapper.S
blobfbf3ce23923335747a5c9a8cf2b973c63f687a28
1 #include "config.h"
3 #define GLUE(a, b) a ## b
4 #define JOIN(a, b) GLUE(a, b)
5 #define MANGLE(s)  JOIN(EXTERN_ASM, s)
7 .data
8 .globl MANGLE(caller_return)
9 MANGLE(caller_return):
10         .long 0
11 .globl MANGLE(report_entry)
12 MANGLE(report_entry):
13         .long MANGLE(null_call)
14 .globl MANGLE(report_ret)
15 MANGLE(report_ret):
16         .long MANGLE(null_call)
17 .global MANGLE(wrapper_target)
18 MANGLE(wrapper_target):
19         .long MANGLE(null_call)
21 .text
22 .globl MANGLE(null_call)
23         .type MANGLE(null_call), @function
24         .balign 16,0x90
25 MANGLE(null_call):
26         ret
27 .globl MANGLE(wrapper)
28         .type MANGLE(wrapper), @function
29         .balign 16,0x90
30 MANGLE(wrapper):
31         pusha                   # store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI)
32         pushf                   # store flags
34         push %ebp               # set up a stack frame
35         movl %esp, %ebp
37         leal 4(%ebp), %eax      # push flags addr
38         push %eax
39         leal 8(%ebp), %eax      # push registers addr
40         push %eax
42         leal 40(%ebp), %edx
43         movl (%ebp), %eax
44         subl %edx, %eax
45         push %eax
46         push %edx
48         call *MANGLE(report_entry)      # report entry
50         test %eax, %eax
51         jnz .Ldone
53         leave                   # restore %esp, %ebp
54         popf                    # restore flags
55         popa                    # restore registers
57         popl MANGLE(caller_return)      # switch return addresses
58         pushl $.Lwrapper_return
60         jmp *MANGLE(wrapper_target)     # wrapper_target should return at .Lwrapper_return
62         .balign 16, 0x90
63 .Lwrapper_return:
64         pushl MANGLE(caller_return)     # restore the original return address
65         pusha                   # more for reference sake here
66         pushf
68         push %ebp               # set up a stack frame
69         movl %esp, %ebp
71         leal 4(%ebp), %eax      # push flags addr
72         push %eax
73         leal 8(%ebp), %eax      # push registers addr
74         push %eax
76         leal 40(%ebp), %edx     # push stack top address (relative to our entry)
77         movl (%ebp), %eax
78         subl %edx, %eax         # calculate difference between entry and previous frame
79         push %eax
80         push %edx
82         call *MANGLE(report_ret)        # report the return information (same args)
83 .Ldone:
85         leave
86         popf
87         popa
88         ret