No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hppa / spmath / divsir.c
blobaeb9f56542eb2b59c0620a632f0e87ab46ec55ce
1 /* $NetBSD: divsir.c,v 1.3 2005/12/11 12:17:40 christos Exp $ */
3 /* $OpenBSD: divsir.c,v 1.5 2001/03/29 03:58:18 mickey Exp $ */
5 /*
6 * Copyright 1996 1995 by Open Software Foundation, Inc.
7 * All Rights Reserved
9 * Permission to use, copy, modify, and distribute this software and
10 * its documentation for any purpose and without fee is hereby granted,
11 * provided that the above copyright notice appears in all copies and
12 * that both the copyright notice and this permission notice appear in
13 * supporting documentation.
15 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
17 * FOR A PARTICULAR PURPOSE.
19 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
22 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
23 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 * pmk1.1
30 * (c) Copyright 1986 HEWLETT-PACKARD COMPANY
32 * To anyone who acknowledges that this file is provided "AS IS"
33 * without any express or implied warranty:
34 * permission to use, copy, modify, and distribute this file
35 * for any purpose is hereby granted without fee, provided that
36 * the above copyright notice and this notice appears in all
37 * copies, and that the name of Hewlett-Packard Company not be
38 * used in advertising or publicity pertaining to distribution
39 * of the software without specific, written prior permission.
40 * Hewlett-Packard Company makes no representations about the
41 * suitability of this software for any purpose.
44 #include <sys/cdefs.h>
45 __KERNEL_RCSID(0, "$NetBSD: divsir.c,v 1.3 2005/12/11 12:17:40 christos Exp $");
47 #include "md.h"
49 void
50 divsir(opnd1,opnd2,result)
52 int opnd1, opnd2;
53 struct mdsfu_register *result;
55 int sign, op1_sign;
57 /* check divisor for zero */
58 if (opnd2 == 0) {
59 overflow = true;
60 return;
63 /* get sign of result */
64 sign = opnd1 ^ opnd2;
66 /* get absolute value of operands */
67 if (opnd1 < 0) {
68 opnd1 = -opnd1;
69 op1_sign = true;
71 else op1_sign = false;
72 if (opnd2 < 0) opnd2 = -opnd2;
74 /* check for opnd2 = -2**31 */
75 if (opnd2 + opnd2 == 0) {
76 if (opnd1 == opnd2) {
77 result_hi = 0; /* remainder = 0 */
78 result_lo = 1;
80 else {
81 result_hi = opnd1; /* remainder = opnd1 */
82 result_lo = 0;
85 else {
86 /* do the divide */
87 divu(0,opnd1,opnd2,result);
90 * check for overflow
92 * at this point, the only way we can get overflow
93 * is with opnd1 = -2**31 and opnd2 = -1
95 if (sign>0 && result_lo<0) {
96 overflow = true;
97 return;
100 overflow = false;
102 /* return appropriately signed remainder and result */
103 if (op1_sign) result_hi = -result_hi;
104 if (sign<0) result_lo = -result_lo;
105 return;