1*25c28e83SPiotr Jasiukajtis/* 2*25c28e83SPiotr Jasiukajtis * CDDL HEADER START 3*25c28e83SPiotr Jasiukajtis * 4*25c28e83SPiotr Jasiukajtis * The contents of this file are subject to the terms of the 5*25c28e83SPiotr Jasiukajtis * Common Development and Distribution License (the "License"). 6*25c28e83SPiotr Jasiukajtis * You may not use this file except in compliance with the License. 7*25c28e83SPiotr Jasiukajtis * 8*25c28e83SPiotr Jasiukajtis * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*25c28e83SPiotr Jasiukajtis * or http://www.opensolaris.org/os/licensing. 10*25c28e83SPiotr Jasiukajtis * See the License for the specific language governing permissions 11*25c28e83SPiotr Jasiukajtis * and limitations under the License. 12*25c28e83SPiotr Jasiukajtis * 13*25c28e83SPiotr Jasiukajtis * When distributing Covered Code, include this CDDL HEADER in each 14*25c28e83SPiotr Jasiukajtis * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*25c28e83SPiotr Jasiukajtis * If applicable, add the following below this CDDL HEADER, with the 16*25c28e83SPiotr Jasiukajtis * fields enclosed by brackets "[]" replaced with your own identifying 17*25c28e83SPiotr Jasiukajtis * information: Portions Copyright [yyyy] [name of copyright owner] 18*25c28e83SPiotr Jasiukajtis * 19*25c28e83SPiotr Jasiukajtis * CDDL HEADER END 20*25c28e83SPiotr Jasiukajtis */ 21*25c28e83SPiotr Jasiukajtis/* 22*25c28e83SPiotr Jasiukajtis * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 23*25c28e83SPiotr Jasiukajtis */ 24*25c28e83SPiotr Jasiukajtis/* 25*25c28e83SPiotr Jasiukajtis * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 26*25c28e83SPiotr Jasiukajtis * Use is subject to license terms. 27*25c28e83SPiotr Jasiukajtis */ 28*25c28e83SPiotr Jasiukajtis 29*25c28e83SPiotr Jasiukajtis .file "nextafterf.s" 30*25c28e83SPiotr Jasiukajtis 31*25c28e83SPiotr Jasiukajtis#include "libm.h" 32*25c28e83SPiotr JasiukajtisLIBM_ANSI_PRAGMA_WEAK(nextafterf,function) 33*25c28e83SPiotr Jasiukajtis 34*25c28e83SPiotr Jasiukajtis .data 35*25c28e83SPiotr Jasiukajtis .align 4 36*25c28e83SPiotr JasiukajtisFmaxf: .long 0x7f7fffff 37*25c28e83SPiotr JasiukajtisFminf: .long 0x1 38*25c28e83SPiotr Jasiukajtisftmpf: .long 0 39*25c28e83SPiotr Jasiukajtis 40*25c28e83SPiotr Jasiukajtis 41*25c28e83SPiotr Jasiukajtis ENTRY(nextafterf) 42*25c28e83SPiotr Jasiukajtis pushl %ebp 43*25c28e83SPiotr Jasiukajtis movl %esp,%ebp 44*25c28e83SPiotr Jasiukajtis movl $0,%eax /// upper half of %eax must be initialized 45*25c28e83SPiotr Jasiukajtis flds 12(%ebp) / y 46*25c28e83SPiotr Jasiukajtis subl $4,%esp 47*25c28e83SPiotr Jasiukajtis flds 8(%ebp) / x, y 48*25c28e83SPiotr Jasiukajtis fucom / x : y 49*25c28e83SPiotr Jasiukajtis fstsw %ax 50*25c28e83SPiotr Jasiukajtis sahf 51*25c28e83SPiotr Jasiukajtis jp .NaN 52*25c28e83SPiotr Jasiukajtis je .equal 53*25c28e83SPiotr Jasiukajtis fstp %st(1) / x 54*25c28e83SPiotr Jasiukajtis ja .bigger 55*25c28e83SPiotr Jasiukajtis / x < y 56*25c28e83SPiotr Jasiukajtis ftst / x : 0 57*25c28e83SPiotr Jasiukajtis movl $0x1,-4(%ebp) / -4(%ebp) contains Fminf 58*25c28e83SPiotr Jasiukajtis fnstsw %ax 59*25c28e83SPiotr Jasiukajtis sahf 60*25c28e83SPiotr Jasiukajtis je .final 61*25c28e83SPiotr Jasiukajtis ja .addulp 62*25c28e83SPiotr Jasiukajtis jb .subulp 63*25c28e83SPiotr Jasiukajtis.bigger: 64*25c28e83SPiotr Jasiukajtis / x > y 65*25c28e83SPiotr Jasiukajtis ftst / x : 0 66*25c28e83SPiotr Jasiukajtis movl $0x80000001,-4(%ebp) / -4(%ebp) contains -Fminf 67*25c28e83SPiotr Jasiukajtis fnstsw %ax 68*25c28e83SPiotr Jasiukajtis sahf 69*25c28e83SPiotr Jasiukajtis je .final 70*25c28e83SPiotr Jasiukajtis jb .addulp 71*25c28e83SPiotr Jasiukajtis.subulp: 72*25c28e83SPiotr Jasiukajtis movl 8(%ebp),%eax / x 73*25c28e83SPiotr Jasiukajtis subl $1,%eax / x - ulp 74*25c28e83SPiotr Jasiukajtis movl %eax,-4(%ebp) 75*25c28e83SPiotr Jasiukajtis jmp .final 76*25c28e83SPiotr Jasiukajtis.addulp: 77*25c28e83SPiotr Jasiukajtis movl 8(%ebp),%eax / x 78*25c28e83SPiotr Jasiukajtis addl $1,%eax / x + ulp 79*25c28e83SPiotr Jasiukajtis movl %eax,-4(%ebp) 80*25c28e83SPiotr Jasiukajtis 81*25c28e83SPiotr Jasiukajtis.final: 82*25c28e83SPiotr Jasiukajtis fstp %st(0) / empty 83*25c28e83SPiotr Jasiukajtis flds -4(%ebp) / z 84*25c28e83SPiotr Jasiukajtis andl $0x7f800000,%eax 85*25c28e83SPiotr Jasiukajtis jz .underflow 86*25c28e83SPiotr Jasiukajtis cmpl $0x7f800000,%eax 87*25c28e83SPiotr Jasiukajtis je .overflow 88*25c28e83SPiotr Jasiukajtis jmp .return 89*25c28e83SPiotr Jasiukajtis.overflow: 90*25c28e83SPiotr Jasiukajtis PIC_SETUP(1) 91*25c28e83SPiotr Jasiukajtis flds PIC_L(Fmaxf) / Fmaxf, z 92*25c28e83SPiotr Jasiukajtis fmul %st(0),%st / overflow-to-Inf, z 93*25c28e83SPiotr Jasiukajtis fstps PIC_L(ftmpf) / z & create overflow signal 94*25c28e83SPiotr Jasiukajtis PIC_WRAPUP 95*25c28e83SPiotr Jasiukajtis jmp .return 96*25c28e83SPiotr Jasiukajtis.underflow: 97*25c28e83SPiotr Jasiukajtis PIC_SETUP(2) 98*25c28e83SPiotr Jasiukajtis flds PIC_L(Fminf) / Fminf, z 99*25c28e83SPiotr Jasiukajtis fmul %st(0),%st / underflow-to-0, z 100*25c28e83SPiotr Jasiukajtis fstps PIC_L(ftmpf) / z & create underflow signal 101*25c28e83SPiotr Jasiukajtis PIC_WRAPUP 102*25c28e83SPiotr Jasiukajtis jmp .return 103*25c28e83SPiotr Jasiukajtis.equal: 104*25c28e83SPiotr Jasiukajtis fstp %st(0) / C99 says to return y when x == y 105*25c28e83SPiotr Jasiukajtis jmp .return 106*25c28e83SPiotr Jasiukajtis.NaN: 107*25c28e83SPiotr Jasiukajtis faddp %st,%st(1) / x+y 108*25c28e83SPiotr Jasiukajtis.return: 109*25c28e83SPiotr Jasiukajtis fwait 110*25c28e83SPiotr Jasiukajtis leave 111*25c28e83SPiotr Jasiukajtis ret 112*25c28e83SPiotr Jasiukajtis .align 4 113*25c28e83SPiotr Jasiukajtis SET_SIZE(nextafterf) 114