Home | History | Annotate | Line # | Download | only in i386
systfloat.S revision 1.2
      1  1.2  ross /* $NetBSD: systfloat.S,v 1.2 2001/03/13 07:43:19 ross Exp $ */
      2  1.2  ross 
      3  1.2  ross /* This is a derivative work. */
      4  1.2  ross 
      5  1.2  ross /*-
      6  1.2  ross  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      7  1.2  ross  * All rights reserved.
      8  1.2  ross  *
      9  1.2  ross  * This code is derived from software contributed to The NetBSD Foundation
     10  1.2  ross  * by Ross Harvey.
     11  1.2  ross  *
     12  1.2  ross  * Redistribution and use in source and binary forms, with or without
     13  1.2  ross  * modification, are permitted provided that the following conditions
     14  1.2  ross  * are met:
     15  1.2  ross  * 1. Redistributions of source code must retain the above copyright
     16  1.2  ross  *    notice, this list of conditions and the following disclaimer.
     17  1.2  ross  * 2. Redistributions in binary form must reproduce the above copyright
     18  1.2  ross  *    notice, this list of conditions and the following disclaimer in the
     19  1.2  ross  *    documentation and/or other materials provided with the distribution.
     20  1.2  ross  * 3. All advertising materials mentioning features or use of this software
     21  1.2  ross  *    must display the following acknowledgement:
     22  1.2  ross  *        This product includes software developed by the NetBSD
     23  1.2  ross  *        Foundation, Inc. and its contributors.
     24  1.2  ross  * 4. Neither the name of The NetBSD Foundation nor the names of its
     25  1.2  ross  *    contributors may be used to endorse or promote products derived
     26  1.2  ross  *    from this software without specific prior written permission.
     27  1.2  ross  *
     28  1.2  ross  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     29  1.2  ross  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     30  1.2  ross  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     31  1.2  ross  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     32  1.2  ross  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     33  1.2  ross  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     34  1.2  ross  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     35  1.2  ross  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     36  1.2  ross  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     37  1.2  ross  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     38  1.2  ross  * POSSIBILITY OF SUCH DAMAGE.
     39  1.2  ross  */
     40  1.1  ross 
     41  1.1  ross /*
     42  1.1  ross ===============================================================================
     43  1.1  ross 
     44  1.1  ross This GNU assembler source file is part of TestFloat, Release 2a, a package
     45  1.1  ross of programs for testing the correctness of floating-point arithmetic
     46  1.1  ross complying to the IEC/IEEE Standard for Floating-Point.
     47  1.1  ross 
     48  1.1  ross Written by John R. Hauser.  More information is available through the Web
     49  1.1  ross page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
     50  1.1  ross 
     51  1.1  ross THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
     52  1.1  ross has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
     53  1.1  ross TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
     54  1.1  ross PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
     55  1.1  ross AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
     56  1.1  ross 
     57  1.1  ross Derivative works are acceptable, even for commercial purposes, so long as
     58  1.1  ross (1) they include prominent notice that the work is derivative, and (2) they
     59  1.1  ross include prominent notice akin to these four paragraphs for those parts of
     60  1.1  ross this code that are retained.
     61  1.1  ross 
     62  1.1  ross ===============================================================================
     63  1.1  ross */
     64  1.1  ross 
     65  1.1  ross 	.text
     66  1.1  ross 
     67  1.1  ross /*
     68  1.1  ross -------------------------------------------------------------------------------
     69  1.1  ross -------------------------------------------------------------------------------
     70  1.1  ross */
     71  1.2  ross 
     72  1.2  ross #include <machine/asm.h>
     73  1.2  ross 
     74  1.2  ross ENTRY(syst_int32_to_floatx80)
     75  1.1  ross 	fildl 8(%esp)
     76  1.1  ross 	movl 4(%esp),%eax
     77  1.1  ross 	fstpt (%eax)
     78  1.1  ross 	ret $4
     79  1.1  ross 
     80  1.1  ross /*
     81  1.1  ross -------------------------------------------------------------------------------
     82  1.1  ross -------------------------------------------------------------------------------
     83  1.1  ross */
     84  1.2  ross 
     85  1.2  ross ENTRY(syst_int64_to_floatx80)
     86  1.1  ross 	fildq 8(%esp)
     87  1.1  ross 	movl 4(%esp),%eax
     88  1.1  ross 	fstpt (%eax)
     89  1.1  ross 	ret $4
     90  1.1  ross 
     91  1.1  ross /*
     92  1.1  ross -------------------------------------------------------------------------------
     93  1.1  ross -------------------------------------------------------------------------------
     94  1.1  ross */
     95  1.2  ross ENTRY(syst_float32_to_floatx80)
     96  1.1  ross 	flds 8(%esp)
     97  1.1  ross 	movl 4(%esp),%eax
     98  1.1  ross 	fstpt (%eax)
     99  1.1  ross 	ret $4
    100  1.1  ross 
    101  1.1  ross /*
    102  1.1  ross -------------------------------------------------------------------------------
    103  1.1  ross -------------------------------------------------------------------------------
    104  1.1  ross */
    105  1.2  ross ENTRY(syst_float64_to_floatx80)
    106  1.1  ross 	fldl 8(%esp)
    107  1.1  ross 	movl 4(%esp),%eax
    108  1.1  ross 	fstpt (%eax)
    109  1.1  ross 	ret $4
    110  1.1  ross 
    111  1.1  ross /*
    112  1.1  ross -------------------------------------------------------------------------------
    113  1.1  ross -------------------------------------------------------------------------------
    114  1.1  ross */
    115  1.2  ross ENTRY(syst_floatx80_to_int32)
    116  1.1  ross 	fldt 4(%esp)
    117  1.1  ross 	subl $4,%esp
    118  1.1  ross 	fistpl (%esp)
    119  1.1  ross 	movl (%esp),%eax
    120  1.1  ross 	addl $4,%esp
    121  1.1  ross 	ret
    122  1.1  ross 
    123  1.1  ross /*
    124  1.1  ross -------------------------------------------------------------------------------
    125  1.1  ross -------------------------------------------------------------------------------
    126  1.1  ross */
    127  1.2  ross ENTRY(syst_floatx80_to_int64)
    128  1.1  ross 	fldt 4(%esp)
    129  1.1  ross 	subl $8,%esp
    130  1.1  ross 	fistpq (%esp)
    131  1.1  ross 	movl (%esp),%eax
    132  1.1  ross 	movl 4(%esp),%edx
    133  1.1  ross 	addl $8,%esp
    134  1.1  ross 	ret
    135  1.1  ross 
    136  1.1  ross /*
    137  1.1  ross -------------------------------------------------------------------------------
    138  1.1  ross -------------------------------------------------------------------------------
    139  1.1  ross */
    140  1.2  ross ENTRY(syst_floatx80_to_float32)
    141  1.1  ross 	fldt 4(%esp)
    142  1.1  ross 	subl $4,%esp
    143  1.1  ross 	fstps (%esp)
    144  1.1  ross 	movl (%esp),%eax
    145  1.1  ross 	addl $4,%esp
    146  1.1  ross 	ret
    147  1.1  ross 
    148  1.1  ross /*
    149  1.1  ross -------------------------------------------------------------------------------
    150  1.1  ross -------------------------------------------------------------------------------
    151  1.1  ross */
    152  1.2  ross ENTRY(syst_floatx80_to_float64)
    153  1.1  ross 	fldt 4(%esp)
    154  1.1  ross 	subl $8,%esp
    155  1.1  ross 	fstpl (%esp)
    156  1.1  ross 	movl 4(%esp),%edx
    157  1.1  ross 	movl (%esp),%eax
    158  1.1  ross 	addl $8,%esp
    159  1.1  ross 	ret
    160  1.1  ross 
    161  1.1  ross /*
    162  1.1  ross -------------------------------------------------------------------------------
    163  1.1  ross -------------------------------------------------------------------------------
    164  1.1  ross */
    165  1.2  ross ENTRY(syst_floatx80_round_to_int)
    166  1.1  ross 	fldt 8(%esp)
    167  1.1  ross 	frndint
    168  1.1  ross 	movl 4(%esp),%eax
    169  1.1  ross 	fstpt (%eax)
    170  1.1  ross 	ret $4
    171  1.1  ross 
    172  1.1  ross /*
    173  1.1  ross -------------------------------------------------------------------------------
    174  1.1  ross -------------------------------------------------------------------------------
    175  1.1  ross */
    176  1.2  ross ENTRY(syst_floatx80_add)
    177  1.1  ross 	fldt 8(%esp)
    178  1.1  ross 	fldt 20(%esp)
    179  1.1  ross 	faddp
    180  1.1  ross 	movl 4(%esp),%eax
    181  1.1  ross 	fstpt (%eax)
    182  1.1  ross 	ret $4
    183  1.1  ross 
    184  1.1  ross /*
    185  1.1  ross -------------------------------------------------------------------------------
    186  1.1  ross -------------------------------------------------------------------------------
    187  1.1  ross */
    188  1.2  ross ENTRY(syst_floatx80_sub)
    189  1.1  ross 	fldt 8(%esp)
    190  1.1  ross 	fldt 20(%esp)
    191  1.1  ross 	fsubrp
    192  1.1  ross 	movl 4(%esp),%eax
    193  1.1  ross 	fstpt (%eax)
    194  1.1  ross 	ret $4
    195  1.1  ross 
    196  1.1  ross /*
    197  1.1  ross -------------------------------------------------------------------------------
    198  1.1  ross -------------------------------------------------------------------------------
    199  1.1  ross */
    200  1.2  ross ENTRY(syst_floatx80_mul)
    201  1.1  ross 	fldt 8(%esp)
    202  1.1  ross 	fldt 20(%esp)
    203  1.1  ross 	fmulp
    204  1.1  ross 	movl 4(%esp),%eax
    205  1.1  ross 	fstpt (%eax)
    206  1.1  ross 	ret $4
    207  1.1  ross 
    208  1.1  ross /*
    209  1.1  ross -------------------------------------------------------------------------------
    210  1.1  ross -------------------------------------------------------------------------------
    211  1.1  ross */
    212  1.2  ross ENTRY(syst_floatx80_div)
    213  1.1  ross 	fldt 8(%esp)
    214  1.1  ross 	fldt 20(%esp)
    215  1.1  ross 	fdivrp
    216  1.1  ross 	movl 4(%esp),%eax
    217  1.1  ross 	fstpt (%eax)
    218  1.1  ross 	ret $4
    219  1.1  ross 
    220  1.1  ross /*
    221  1.1  ross -------------------------------------------------------------------------------
    222  1.1  ross -------------------------------------------------------------------------------
    223  1.1  ross */
    224  1.2  ross ENTRY(syst_floatx80_rem)
    225  1.1  ross 	fldt 20(%esp)
    226  1.1  ross 	fldt 8(%esp)
    227  1.1  ross floatx80_rem_loop:
    228  1.1  ross 	fprem1
    229  1.1  ross 	fnstsw %ax
    230  1.1  ross 	btw $10,%ax
    231  1.1  ross 	jc floatx80_rem_loop
    232  1.1  ross 	movl 4(%esp),%eax
    233  1.1  ross 	fstpt (%eax)
    234  1.1  ross 	fstp %st(0)
    235  1.1  ross 	ret $4
    236  1.1  ross 
    237  1.1  ross /*
    238  1.1  ross -------------------------------------------------------------------------------
    239  1.1  ross -------------------------------------------------------------------------------
    240  1.1  ross */
    241  1.2  ross ENTRY(syst_floatx80_sqrt)
    242  1.1  ross 	fldt 8(%esp)
    243  1.1  ross 	fsqrt
    244  1.1  ross 	movl 4(%esp),%eax
    245  1.1  ross 	fstpt (%eax)
    246  1.1  ross 	ret $4
    247  1.1  ross 
    248  1.1  ross /*
    249  1.1  ross -------------------------------------------------------------------------------
    250  1.1  ross -------------------------------------------------------------------------------
    251  1.1  ross */
    252  1.2  ross ENTRY(syst_floatx80_eq)
    253  1.1  ross 	fldt 16(%esp)
    254  1.1  ross 	fldt 4(%esp)
    255  1.1  ross 	fucompp
    256  1.1  ross 	fnstsw %ax
    257  1.1  ross 	andw $17664,%ax
    258  1.1  ross 	cmpw $16384,%ax
    259  1.1  ross 	seteb %al
    260  1.1  ross 	movzb %al,%eax
    261  1.1  ross 	ret
    262  1.1  ross 
    263  1.1  ross /*
    264  1.1  ross -------------------------------------------------------------------------------
    265  1.1  ross -------------------------------------------------------------------------------
    266  1.1  ross */
    267  1.2  ross ENTRY(syst_floatx80_le)
    268  1.1  ross 	fldt 4(%esp)
    269  1.1  ross 	fldt 16(%esp)
    270  1.1  ross 	fcompp
    271  1.1  ross 	fnstsw %ax
    272  1.1  ross 	notl %eax
    273  1.1  ross 	shrl $8,%eax
    274  1.1  ross 	andl $1,%eax
    275  1.1  ross 	ret
    276  1.1  ross 
    277  1.1  ross /*
    278  1.1  ross -------------------------------------------------------------------------------
    279  1.1  ross -------------------------------------------------------------------------------
    280  1.1  ross */
    281  1.2  ross ENTRY(syst_floatx80_lt)
    282  1.1  ross 	fldt 4(%esp)
    283  1.1  ross 	fldt 16(%esp)
    284  1.1  ross 	fcompp
    285  1.1  ross 	fnstsw %ax
    286  1.1  ross 	andw $17664,%ax
    287  1.1  ross 	setzb %al
    288  1.1  ross 	movzb %al,%eax
    289  1.1  ross 	ret
    290  1.1  ross 
    291  1.1  ross /*
    292  1.1  ross -------------------------------------------------------------------------------
    293  1.1  ross -------------------------------------------------------------------------------
    294  1.1  ross */
    295  1.2  ross ENTRY(syst_floatx80_eq_signaling)
    296  1.1  ross 	fldt 16(%esp)
    297  1.1  ross 	fldt 4(%esp)
    298  1.1  ross 	fcompp
    299  1.1  ross 	fnstsw %ax
    300  1.1  ross 	andw $17664,%ax
    301  1.1  ross 	cmpw $16384,%ax
    302  1.1  ross 	seteb %al
    303  1.1  ross 	movzb %al,%eax
    304  1.1  ross 	ret
    305  1.1  ross 
    306  1.1  ross /*
    307  1.1  ross -------------------------------------------------------------------------------
    308  1.1  ross -------------------------------------------------------------------------------
    309  1.1  ross */
    310  1.2  ross ENTRY(syst_floatx80_le_quiet)
    311  1.1  ross 	fldt 4(%esp)
    312  1.1  ross 	fldt 16(%esp)
    313  1.1  ross 	fucompp
    314  1.1  ross 	fnstsw %ax
    315  1.1  ross 	notl %eax
    316  1.1  ross 	shrl $8,%eax
    317  1.1  ross 	andl $1,%eax
    318  1.1  ross 	ret
    319  1.1  ross 
    320  1.1  ross /*
    321  1.1  ross -------------------------------------------------------------------------------
    322  1.1  ross -------------------------------------------------------------------------------
    323  1.1  ross */
    324  1.2  ross 
    325  1.2  ross ENTRY(syst_floatx80_lt_quiet)
    326  1.1  ross 	fldt 4(%esp)
    327  1.1  ross 	fldt 16(%esp)
    328  1.1  ross 	fucompp
    329  1.1  ross 	fnstsw %ax
    330  1.1  ross 	andw $17664,%ax
    331  1.1  ross 	setzb %al
    332  1.1  ross 	movzb %al,%eax
    333  1.1  ross 	ret
    334  1.1  ross 
    335  1.2  ross /*
    336  1.2  ross -------------------------------------------------------------------------------
    337  1.2  ross -------------------------------------------------------------------------------
    338  1.2  ross */
    339  1.2  ross 
    340  1.2  ross ENTRY(syst_floatx80_to_int32_round_to_zero)
    341  1.2  ross 	pushl %ebp
    342  1.2  ross 	movl %esp,%ebp
    343  1.2  ross 	subl $12,%esp
    344  1.2  ross 	fldt 8(%ebp)
    345  1.2  ross 	fnstcw -4(%ebp)
    346  1.2  ross 	movl -4(%ebp),%edx
    347  1.2  ross 	movb $12,%dh
    348  1.2  ross 	movl %edx,-12(%ebp)
    349  1.2  ross 	fldcw -12(%ebp)
    350  1.2  ross 	fistpl -12(%ebp)
    351  1.2  ross 	movl -12(%ebp),%eax
    352  1.2  ross 	fldcw -4(%ebp)
    353  1.2  ross 	leave
    354  1.2  ross 	ret
    355  1.2  ross 
    356  1.2  ross /*
    357  1.2  ross -------------------------------------------------------------------------------
    358  1.2  ross -------------------------------------------------------------------------------
    359  1.2  ross */
    360  1.2  ross 
    361  1.2  ross ENTRY(syst_floatx80_to_int64_round_to_zero)
    362  1.2  ross 	pushl %ebp
    363  1.2  ross 	movl %esp,%ebp
    364  1.2  ross 	subl $12,%esp
    365  1.2  ross 	fldt 8(%ebp)
    366  1.2  ross 	fnstcw -4(%ebp)
    367  1.2  ross 	movl -4(%ebp),%ecx
    368  1.2  ross 	movb $12,%ch
    369  1.2  ross 	movl %ecx,-12(%ebp)
    370  1.2  ross 	fldcw -12(%ebp)
    371  1.2  ross 	fistpq -12(%ebp)
    372  1.2  ross 	movl -12(%ebp),%eax
    373  1.2  ross 	movl -8(%ebp),%edx
    374  1.2  ross 	fldcw -4(%ebp)
    375  1.2  ross 	leave
    376  1.2  ross 	ret
    377