home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gcc-2.4.5 / config / i386 / perform.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-07  |  2.9 KB  |  94 lines

  1. /* Definitions for AT&T assembler syntax for the Intel 80386.
  2.    Copyright (C) 1988 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* Defines to be able to build libgcc.a with GCC.  */
  21.  
  22. /* It might seem that these are not important, since gcc 2 will never
  23.    call libgcc for these functions.  But programs might be linked with
  24.    code compiled by gcc 1, and then these will be used.  */
  25.  
  26. /* The arg names used to be a and b, but `a' appears inside strings
  27.    and that confuses non-ANSI cpp.  */
  28.  
  29. #define perform_udivsi3(arg0,arg1)                    \
  30. {                                    \
  31.   register int dx asm("dx");                        \
  32.   register int ax asm("ax");                        \
  33.                                     \
  34.   dx = 0;                                \
  35.   ax = arg0;                                \
  36.   asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1), "d" (dx)); \
  37.   return ax;                                \
  38. }
  39.  
  40. #define perform_divsi3(arg0,arg1)                    \
  41. {                                    \
  42.   register int dx asm("dx");                        \
  43.   register int ax asm("ax");                        \
  44.                                     \
  45.   ax = arg0;                                \
  46.   asm ("cltd\n\tidivl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1)); \
  47.   return ax;                                \
  48. }
  49.  
  50. #define perform_umodsi3(arg0,arg1)                    \
  51. {                                    \
  52.   register int dx asm("dx");                        \
  53.   register int ax asm("ax");                        \
  54.                                     \
  55.   dx = 0;                                \
  56.   ax = arg0;                                \
  57.   asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1), "d" (dx)); \
  58.   return dx;                                \
  59. }
  60.  
  61. #define perform_modsi3(arg0,arg1)                    \
  62. {                                    \
  63.   register int dx asm("dx");                        \
  64.   register int ax asm("ax");                        \
  65.                                     \
  66.   ax = arg0;                                \
  67.   asm ("cltd\n\tidivl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1)); \
  68.   return dx;                                \
  69. }
  70.  
  71. #define perform_fixdfsi(arg0)                        \
  72. {                                    \
  73.   auto unsigned short ostatus;                        \
  74.   auto unsigned short nstatus;                        \
  75.   auto int ret;                                \
  76.   auto double tmp;                            \
  77.                                     \
  78.   &ostatus;            /* guarantee these land in memory */    \
  79.   &nstatus;                                \
  80.   &ret;                                    \
  81.   &tmp;                                    \
  82.                                     \
  83.   asm volatile ("fnstcw %0" : "=m" (ostatus));                \
  84.   nstatus = ostatus | 0x0c00;                        \
  85.   asm volatile ("fldcw %0" : /* no outputs */ : "m" (nstatus));        \
  86.   tmp = arg0;                                \
  87.   asm volatile ("fldl %0" : /* no outputs */ : "m" (tmp));        \
  88.   asm volatile ("fistpl %0" : "=m" (ret));                \
  89.   asm volatile ("fldcw %0" : /* no outputs */ : "m" (ostatus));        \
  90.                                     \
  91.   return ret;                                \
  92. }
  93.  
  94.