1 dnl x86 calling conventions checking.
3 dnl Copyright 2000, 2003 Free Software Foundation, Inc.
5 dnl This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software; you can redistribute it and/or
8 dnl modify it under the terms of the GNU Lesser General Public License as
9 dnl published by the Free Software Foundation; either version 3 of the
10 dnl License, or (at your option) any later version.
12 dnl The GNU MP Library is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 dnl Lesser General Public License for more details.
17 dnl You should have received a copy of the GNU Lesser General Public License
18 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
21 include(`../config.m4')
24 C void x86_fldcw (unsigned short cw);
26 C Execute an fldcw, setting the x87 control word to cw.
34 C unsigned short x86_fstcw (void);
36 C Execute an fstcw, returning the current x87 control word.
47 dnl Instrumented profiling doesn't come out quite right below, since we
48 dnl don't do an actual "ret". There's only a few instructions here, so
49 dnl there's no great need to get them separately accounted, just let them
50 dnl get attributed to the caller.
52 ifelse(WANT_PROFILING,instrument,
53 `define(`WANT_PROFILING',no)')
56 C int calling_conventions (...);
58 C The global variable "calling_conventions_function" is the function to
59 C call, with the arguments as passed here.
61 C Perhaps the finit should be done only if the tags word isn't clear, but
62 C nothing uses the rounding mode or anything at the moment.
70 PROLOGUE(calling_conventions)
72 movl %eax, G(calling_conventions_retaddr)
74 movl $L(return), (%esp)
76 movl %ebx, G(calling_conventions_save_ebx)
77 movl %esi, G(calling_conventions_save_esi)
78 movl %edi, G(calling_conventions_save_edi)
79 movl %ebp, G(calling_conventions_save_ebp)
81 movl $0x01234567, %ebx
82 movl $0x89ABCDEF, %esi
83 movl $0xFEDCBA98, %edi
84 movl $0x76543210, %ebp
86 C try to provoke a problem by starting with junk in the registers,
87 C especially in %eax and %edx which will be return values
88 movl $0x70246135, %eax
89 movl $0x8ACE9BDF, %ecx
90 movl $0xFDB97531, %edx
92 jmp *G(calling_conventions_function)
95 movl %ebx, G(calling_conventions_ebx)
96 movl %esi, G(calling_conventions_esi)
97 movl %edi, G(calling_conventions_edi)
98 movl %ebp, G(calling_conventions_ebp)
102 movl %ebx, G(calling_conventions_eflags)
104 fstenv G(calling_conventions_fenv)
107 movl G(calling_conventions_save_ebx), %ebx
108 movl G(calling_conventions_save_esi), %esi
109 movl G(calling_conventions_save_edi), %edi
110 movl G(calling_conventions_save_ebp), %ebp
112 jmp *G(calling_conventions_retaddr)