x86call.asm revision 1.1.1.1
1dnl x86 calling conventions checking. 2 3dnl Copyright 2000, 2003 Free Software Foundation, Inc. 4dnl 5dnl This file is part of the GNU MP Library. 6dnl 7dnl The GNU MP Library is free software; you can redistribute it and/or 8dnl modify it under the terms of the GNU Lesser General Public License as 9dnl published by the Free Software Foundation; either version 3 of the 10dnl License, or (at your option) any later version. 11dnl 12dnl The GNU MP Library is distributed in the hope that it will be useful, 13dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15dnl Lesser General Public License for more details. 16dnl 17dnl You should have received a copy of the GNU Lesser General Public License 18dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 20 21include(`../config.m4') 22 23 24C void x86_fldcw (unsigned short cw); 25C 26C Execute an fldcw, setting the x87 control word to cw. 27 28PROLOGUE(x86_fldcw) 29 fldcw 4(%esp) 30 ret 31EPILOGUE() 32 33 34C unsigned short x86_fstcw (void); 35C 36C Execute an fstcw, returning the current x87 control word. 37 38PROLOGUE(x86_fstcw) 39 xorl %eax, %eax 40 pushl %eax 41 fstcw (%esp) 42 popl %eax 43 ret 44EPILOGUE() 45 46 47dnl Instrumented profiling doesn't come out quite right below, since we 48dnl don't do an actual "ret". There's only a few instructions here, so 49dnl there's no great need to get them separately accounted, just let them 50dnl get attributed to the caller. 51 52ifelse(WANT_PROFILING,instrument, 53`define(`WANT_PROFILING',no)') 54 55 56C int calling_conventions (...); 57C 58C The global variable "calling_conventions_function" is the function to 59C call, with the arguments as passed here. 60C 61C Perhaps the finit should be done only if the tags word isn't clear, but 62C nothing uses the rounding mode or anything at the moment. 63 64define(G, 65m4_assert_numargs(1) 66`GSYM_PREFIX`'$1') 67 68 .text 69 ALIGN(8) 70PROLOGUE(calling_conventions) 71 movl (%esp), %eax 72 movl %eax, G(calling_conventions_retaddr) 73 74 movl $L(return), (%esp) 75 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) 80 81 movl $0x01234567, %ebx 82 movl $0x89ABCDEF, %esi 83 movl $0xFEDCBA98, %edi 84 movl $0x76543210, %ebp 85 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 91 92 jmp *G(calling_conventions_function) 93 94L(return): 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) 99 100 pushf 101 popl %ebx 102 movl %ebx, G(calling_conventions_eflags) 103 104 fstenv G(calling_conventions_fenv) 105 finit 106 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 111 112 jmp *G(calling_conventions_retaddr) 113 114EPILOGUE() 115 116