1*0d34bfa2Suebayasi/* $NetBSD: fixunsdfsi.S,v 1.14 2014/05/23 02:34:19 uebayasi Exp $ */ 21394f01bSchristos 30b9f5089Scgd/*- 40b9f5089Scgd * Copyright (c) 1990 The Regents of the University of California. 50b9f5089Scgd * All rights reserved. 60b9f5089Scgd * 70b9f5089Scgd * This code is derived from software contributed to Berkeley by 80b9f5089Scgd * William Jolitz. 90b9f5089Scgd * 100b9f5089Scgd * Redistribution and use in source and binary forms, with or without 110b9f5089Scgd * modification, are permitted provided that the following conditions 120b9f5089Scgd * are met: 130b9f5089Scgd * 1. Redistributions of source code must retain the above copyright 140b9f5089Scgd * notice, this list of conditions and the following disclaimer. 150b9f5089Scgd * 2. Redistributions in binary form must reproduce the above copyright 160b9f5089Scgd * notice, this list of conditions and the following disclaimer in the 170b9f5089Scgd * documentation and/or other materials provided with the distribution. 18eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors 190b9f5089Scgd * may be used to endorse or promote products derived from this software 200b9f5089Scgd * without specific prior written permission. 210b9f5089Scgd * 220b9f5089Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 230b9f5089Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 240b9f5089Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 250b9f5089Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 260b9f5089Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 270b9f5089Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 280b9f5089Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 290b9f5089Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 300b9f5089Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 310b9f5089Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 320b9f5089Scgd * SUCH DAMAGE. 33823c3657Sjtc * 34823c3657Sjtc * from: @(#)fixunsdfsi.s 5.1 12/17/90 350b9f5089Scgd */ 360b9f5089Scgd 373f78e35cSjtc#include <machine/asm.h> 38823c3657Sjtc#if defined(LIBC_SCCS) 39*0d34bfa2Suebayasi RCSID("$NetBSD: fixunsdfsi.S,v 1.14 2014/05/23 02:34:19 uebayasi Exp $") 40823c3657Sjtc#endif 410b9f5089Scgd 426be8b83aSjtcENTRY(__fixunsdfsi) 430b9f5089Scgd fldl 4(%esp) /* argument double to accum stack */ 440b9f5089Scgd frndint /* create integer */ 454d12bfcdSjoerg#ifdef __PIC__ 460b9f5089Scgd PIC_PROLOGUE 470b9f5089Scgd leal PIC_GOTOFF(fbiggestsigned),%eax 480b9f5089Scgd PIC_EPILOGUE 490b9f5089Scgd fcoml (%eax) 500b9f5089Scgd#else 519c8862a9Smycroft fcoml fbiggestsigned /* bigger than biggest signed? */ 520b9f5089Scgd#endif 530b9f5089Scgd fstsw %ax 540b9f5089Scgd sahf 55ae621533Schristos jnb 2f 560b9f5089Scgd 570b9f5089Scgd fistpl 4(%esp) 580b9f5089Scgd movl 4(%esp),%eax 590b9f5089Scgd ret 600b9f5089Scgd 61ae621533Schristos2: 624d12bfcdSjoerg#ifdef __PIC__ 630b9f5089Scgd PIC_PROLOGUE 640b9f5089Scgd leal PIC_GOTOFF(fbiggestsigned),%eax 650b9f5089Scgd PIC_EPILOGUE 660b9f5089Scgd fsubl (%eax) 670b9f5089Scgd#else 68417e7a6fSpk fsubl fbiggestsigned /* reduce for proper conversion */ 690b9f5089Scgd#endif 700b9f5089Scgd fistpl 4(%esp) /* convert */ 710b9f5089Scgd movl 4(%esp),%eax 720b9f5089Scgd orl $0x80000000,%eax /* restore bias */ 730b9f5089Scgd ret 74*0d34bfa2SuebayasiEND(__fixunsdfsi) 750b9f5089Scgd 76b53ad3dfSjoergfbiggestsigned: .double 2147483648.0 77