1*58569Sralph/*- 2*58569Sralph * Copyright (c) 1993 The Regents of the University of California. 3*58569Sralph * All rights reserved. 4*58569Sralph * 5*58569Sralph * This code is derived from software contributed to Berkeley by 6*58569Sralph * Ralph Campbell. 7*58569Sralph * 8*58569Sralph * %sccs.include.redist.c% 9*58569Sralph */ 10*58569Sralph 11*58569Sralph#include <machine/machAsmDefs.h> 12*58569Sralph 13*58569Sralph#if defined(LIBC_SCCS) && !defined(lint) 14*58569Sralph ASMSTR("@(#)isinf.s 5.1 (Berkeley) 03/08/93") 15*58569Sralph#endif /* LIBC_SCCS and not lint */ 16*58569Sralph 17*58569Sralph 18*58569Sralph#define DEXP_INF 0x7ff 19*58569Sralph 20*58569Sralph .set noreorder 21*58569Sralph 22*58569Sralph/* 23*58569Sralph * isnan(x) 24*58569Sralph * double x; 25*58569Sralph * 26*58569Sralph * Return true if x is a NAN. 27*58569Sralph */ 28*58569SralphLEAF(isnan) 29*58569Sralph mfc1 v1, $f13 # get MSW of x 30*58569Sralph mfc1 t3, $f12 # get LSW of x 31*58569Sralph sll t1, v1, 1 # get x exponent 32*58569Sralph srl t1, t1, 32 - 11 33*58569Sralph bne t1, DEXP_INF, 2f # is it a finite number? 34*58569Sralph sll t2, v1, 32 - 20 # get x fraction 35*58569Sralph bne t3, zero, 1f # is it a NAN? 36*58569Sralph nop 37*58569Sralph beq t2, zero, 2f # its infinity 38*58569Sralph nop 39*58569Sralph1: 40*58569Sralph j ra 41*58569Sralph li v0, 1 # x is a NAN 42*58569Sralph2: 43*58569Sralph j ra 44*58569Sralph move v0, zero # x is NOT a NAN 45*58569SralphEND(isnan) 46*58569Sralph 47*58569Sralph/* 48*58569Sralph * isinf(x) 49*58569Sralph * double x; 50*58569Sralph * 51*58569Sralph * Return true if x is infinity. 52*58569Sralph */ 53*58569SralphLEAF(isinf) 54*58569Sralph mfc1 v1, $f13 # get MSW of x 55*58569Sralph mfc1 t3, $f12 # get LSW of x 56*58569Sralph sll t1, v1, 1 # get x exponent 57*58569Sralph srl t1, t1, 32 - 11 58*58569Sralph bne t1, DEXP_INF, 1f # is it a finite number? 59*58569Sralph sll t2, v1, 32 - 20 # get x fraction 60*58569Sralph bne t3, zero, 1f # is it a NAN? 61*58569Sralph nop 62*58569Sralph bne t2, zero, 1f # is it a NAN? 63*58569Sralph nop 64*58569Sralph j ra 65*58569Sralph li v0, 1 # x is infinity 66*58569Sralph1: 67*58569Sralph j ra 68*58569Sralph move v0, zero # x is NOT infinity 69*58569SralphEND(isinf) 70