xref: /csrg-svn/lib/libc/mips/gen/isinf.s (revision 61141)
158569Sralph/*-
2*61141Sbostic * Copyright (c) 1993
3*61141Sbostic *	The Regents of the University of California.  All rights reserved.
458569Sralph *
558569Sralph * This code is derived from software contributed to Berkeley by
658569Sralph * Ralph Campbell.
758569Sralph *
858569Sralph * %sccs.include.redist.c%
958569Sralph */
1058569Sralph
1158569Sralph#include <machine/machAsmDefs.h>
1258569Sralph
1358569Sralph#if defined(LIBC_SCCS) && !defined(lint)
14*61141Sbostic	ASMSTR("@(#)isinf.s	8.1 (Berkeley) 06/04/93")
1558569Sralph#endif /* LIBC_SCCS and not lint */
1658569Sralph
1758569Sralph
1858569Sralph#define DEXP_INF	0x7ff
1958569Sralph
2058569Sralph	.set	noreorder
2158569Sralph
2258569Sralph/*
2358569Sralph * isnan(x)
2458569Sralph *	double x;
2558569Sralph *
2658569Sralph * Return true if x is a NAN.
2758569Sralph */
2858569SralphLEAF(isnan)
2958569Sralph	mfc1	v1, $f13		# get MSW of x
3058569Sralph	mfc1	t3, $f12		# get LSW of x
3158569Sralph	sll	t1, v1, 1		# get x exponent
3258569Sralph	srl	t1, t1, 32 - 11
3358569Sralph	bne	t1, DEXP_INF, 2f	# is it a finite number?
3458569Sralph	sll	t2, v1, 32 - 20		# get x fraction
3558569Sralph	bne	t3, zero, 1f		# is it a NAN?
3658569Sralph	nop
3758569Sralph	beq	t2, zero, 2f		# its infinity
3858569Sralph	nop
3958569Sralph1:
4058569Sralph	j	ra
4158569Sralph	li	v0, 1			# x is a NAN
4258569Sralph2:
4358569Sralph	j	ra
4458569Sralph	move	v0, zero		# x is NOT a NAN
4558569SralphEND(isnan)
4658569Sralph
4758569Sralph/*
4858569Sralph * isinf(x)
4958569Sralph *	double x;
5058569Sralph *
5158569Sralph * Return true if x is infinity.
5258569Sralph */
5358569SralphLEAF(isinf)
5458569Sralph	mfc1	v1, $f13		# get MSW of x
5558569Sralph	mfc1	t3, $f12		# get LSW of x
5658569Sralph	sll	t1, v1, 1		# get x exponent
5758569Sralph	srl	t1, t1, 32 - 11
5858569Sralph	bne	t1, DEXP_INF, 1f	# is it a finite number?
5958569Sralph	sll	t2, v1, 32 - 20		# get x fraction
6058569Sralph	bne	t3, zero, 1f		# is it a NAN?
6158569Sralph	nop
6258569Sralph	bne	t2, zero, 1f		# is it a NAN?
6358569Sralph	nop
6458569Sralph	j	ra
6558569Sralph	li	v0, 1			# x is infinity
6658569Sralph1:
6758569Sralph	j	ra
6858569Sralph	move	v0, zero		# x is NOT infinity
6958569SralphEND(isinf)
70