[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.1, Thu Apr 4 06:36:16 1996 UTC (24 years, 11 months ago) by phil
Branch: MAIN
CVS Tags: wrstuden-devbsize-base, wrstuden-devbsize-19991221, wrstuden-devbsize, thorpej_scsipi_nbase, thorpej_scsipi_beforemerge, thorpej_scsipi_base, thorpej_scsipi, thorpej-signal-base, thorpej-signal, thorpej-setroot, thorpej-mips-cache-base, thorpej-mips-cache, thorpej-devvp-base3, thorpej-devvp-base2, thorpej-devvp-base, thorpej-devvp, pre-chs-ubcperf, post-chs-ubcperf, newlock-base, newlock, netbsd-1-6-base, netbsd-1-6-RELEASE, netbsd-1-6-RC3, netbsd-1-6-RC2, netbsd-1-6-RC1, netbsd-1-6-PATCH002-RELEASE, netbsd-1-6-PATCH002-RC4, netbsd-1-6-PATCH002-RC3, netbsd-1-6-PATCH002-RC2, netbsd-1-6-PATCH002-RC1, netbsd-1-6-PATCH002, netbsd-1-6-PATCH001-RELEASE, netbsd-1-6-PATCH001-RC3, netbsd-1-6-PATCH001-RC2, netbsd-1-6-PATCH001-RC1, netbsd-1-6-PATCH001, netbsd-1-6, netbsd-1-5-base, netbsd-1-5-RELEASE, netbsd-1-5-PATCH003, netbsd-1-5-PATCH002, netbsd-1-5-PATCH001, netbsd-1-5-BETA2, netbsd-1-5-BETA, netbsd-1-5-ALPHA2, netbsd-1-5, netbsd-1-4-base, netbsd-1-4-RELEASE, netbsd-1-4-PATCH003, netbsd-1-4-PATCH002, netbsd-1-4-PATCH001, netbsd-1-4, netbsd-1-3-base, netbsd-1-3-RELEASE, netbsd-1-3-PATCH003-CANDIDATE2, netbsd-1-3-PATCH003-CANDIDATE1, netbsd-1-3-PATCH003-CANDIDATE0, netbsd-1-3-PATCH003, netbsd-1-3-PATCH002, netbsd-1-3-PATCH001, netbsd-1-3-BETA, netbsd-1-3, netbsd-1-2-base, netbsd-1-2-RELEASE, netbsd-1-2-PATCH001, netbsd-1-2-BETA, netbsd-1-2, nathanw_sa_before_merge, mrg-vm-swap, minoura-xpg4dl-base, minoura-xpg4dl, marc-pcmcia-bp, marc-pcmcia-base, marc-pcmcia, kqueue-beforemerge, kqueue-base, kqueue-aftermerge, kqueue, kenh-if-detach-base, kenh-if-detach, kame_14_19990705, kame_14_19990628, kame_141_19991130, kame, is-newarp-before-merge, is-newarp-base, is-newarp, ifpoll-base, gmcgarry_ucred_base, gmcgarry_ucred, gmcgarry_ctxsw_base, gmcgarry_ctxsw, gehenna-devsw-base, gehenna-devsw, fvdl_fs64_base, fvdl-softdep-base, fvdl-softdep, eeh-paddr_t-base, eeh-paddr_t, eeh-devprop-base, eeh-devprop, comdex-fall-1999-base, comdex-fall-1999, chs-ubc2-newbase, chs-ubc2-base, chs-ubc2, chs-ubc-base, chs-ubc, bouyer-scsipi
Branch point for: ktrace-lwp

Initial check-in of the ieee fp support for the pc532.
ieee fp support by Ian Dall, NetBSD/pc532 integration by Matthias Pfaller.
Includes setjmp/longjmp added to locore.s.

/*	$NetBSD: ieee_dze.c,v 1.1 1996/04/04 06:36:16 phil 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 "ieee_internal.h"

int ieee_dze(struct operand *op1, struct operand *op2,
	     struct operand *f0_op, int xopcode, state *state)
{
  int user_trap = FPC_TT_NONE;
  unsigned int fsr = state->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;
    }
  }
  state->FSR = fsr;
  return user_trap;
}