summaryrefslogtreecommitdiffstats
path: root/arch/sparc/math-emu/fcmpd.c
blob: 05a460eeeaf651236e3a2998ab08dad1a78ef1f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* $Id: fcmpd.c,v 1.8 1999/05/28 13:41:36 jj Exp $
 * arch/sparc/math-emu/fcmpd.c
 *
 * Copyright (C) 1997, 1999 Jakub Jelinek (jj@ultra.linux.cz)
 * Copyright (C) 1998 Peter Maydell (pmaydell@chiark.greenend.org.uk)
 *
 */

#include "sfp-util.h"
#include "soft-fp.h"
#include "double.h"

int FCMPD(void *rd, void *rs2, void *rs1)
{
	FP_DECL_EX;
	FP_DECL_D(A); FP_DECL_D(B);
	long ret;
	unsigned long fsr;
	
	FP_UNPACK_RAW_DP(A, rs1);
	FP_UNPACK_RAW_DP(B, rs2);
	FP_CMP_D(ret, B, A, 3);
	if (ret == 3 && (FP_ISSIGNAN_D(A) || FP_ISSIGNAN_D(B)))
		FP_SET_EXCEPTION(FP_EX_INVALID);
	if (!FP_INHIBIT_RESULTS) {
		if (ret == -1) ret = 2;
		fsr = *(long *)rd;
		fsr &= ~0xc00;
		fsr |= (ret << 10);
		*(long *)rd = fsr;
	}
	FP_HANDLE_EXCEPTIONS;
}