[BACK]Return to ieee_dze.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / pc532 / fpu

File: [cvs.NetBSD.org] / src / sys / arch / pc532 / fpu / Attic / ieee_dze.c (download)

Revision 1.4, Sun Oct 2 15:07:41 2005 UTC (15 years, 5 months ago) by chs
Branch: MAIN
CVS Tags: yamt-vop-base3, yamt-vop-base2, yamt-vop-base, yamt-vop, yamt-readahead-pervnode, yamt-readahead-perfile, yamt-readahead-base3, yamt-readahead-base2, yamt-readahead-base, yamt-readahead, thorpej-vnode-attr-base, thorpej-vnode-attr, ktrace-lwp-base
Changes since 1.3: +5 -5 lines

make this compile again after stricter warnings and compat changes.

/*	$NetBSD: ieee_dze.c,v 1.4 2005/10/02 15:07:41 chs Exp $	*/

/*
 * IEEE floating point support for NS32081 and NS32381 fpus.
 * Copyright (c) 1995 Ian Dall
 * All Rights Reserved.
 *
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * IAN DALL ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
 * IAN DALL DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
 * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 */
/*
 *	File:	ieee_dze.c
 *	Author:	Ian Dall
 *	Date:	November 1995
 *
 *	Handle divide by zero, generating +-Infty as required.
 *
 * HISTORY
 * 14-Dec-95  Ian Dall (Ian.Dall@dsto.defence.gov.au)
 *	First release.
 *
 */

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ieee_dze.c,v 1.4 2005/10/02 15:07:41 chs Exp $");

#include "ieee_internal.h"

int ieee_dze(struct operand *op1, struct operand *op2,
	     struct operand *f0_op, int xopcode, state *mystate)
{
  int user_trap = FPC_TT_NONE;
  unsigned int fsr = mystate->FSR;
  DP(1, "Divide by zero trap: xopcode = 0x%x\n", xopcode);
  fsr |= FPC_DZF;
  if (fsr & FPC_DZE) {
    /* Users trap handler will fix it */
    user_trap = FPC_TT_DIV0;
  }
  else {
    /* Set dest to + or - infinity ? */
    int sign1 = op2->data.d_bits.sign;
    int sign2 = op1->data.d_bits.sign;
    op2->data = infty;
    op2->data.d_bits.sign = sign1 ^ sign2;
    switch(xopcode) {
    case LOGBF:
      /* logb(0) gives a divide by zero exception according to ieee.
       * No idea if the logbf instruction conforms, but just in case...
       */
      op2->data.d_bits.sign = 1;
    }
  }
  mystate->FSR = fsr;
  return user_trap;
}