Path: utzoo!attcan!uunet!ginosko!gem.mps.ohio-state.edu!apple!motcsd!hpda!hpcuhb!hpcllla!daryl
From: daryl@hpcllla.HP.COM (Daryl Odnert)
Newsgroups: comp.sys.hp
Subject: Re: extreme performance degradation in c compiler on HP9000/835
Message-ID: <3770027@hpcllla.HP.COM>
Date: 27 Sep 89 16:37:16 GMT
References: <721@mit-amt.MEDIA.MIT.EDU>
Organization: Hewlett-Packard Calif. Language Lab
Lines: 51



/*
** void enable_fp_traps( mask )
**    unsigned mask;
**
** This routine sets the trap-enable bits in the HPPA
** floating-point coprocessor.  This routine expects a single
** unsigned value parameter that decribes which traps to enable.
** Only the low order 5 bits are of interest.  All other bits are ignored.
** The bits are assigned as follows:
**     
**       0x1:   inexact result
**       0x2:	underflow
**       0x4:	overflow
**       0x8:   division by zero
**       0x10:  invalid operation
**
** For example, to enable all floating-point traps, execute the following
** call from your C program:
**         enable_fp_traps ( 0x1F );
**
** To compile this routine, just use save it in a file with a .s suffix
** and envoke cc on it.
** 
** For more information on the HPPA floating-point coprocessor, see
** chapter 6 of the HP Precision Architecture and Instruction Set
** Reference Manual, HP Part No. 09740-90014.
**
** Author: Daryl Odnert
** Unlimited permission to copy is granted.
** Mail problems/questions to:
**      daryl%hpcllla@hplabs.hp.com  or  hplabs!hpcllla!daryl
** 
*/
        .SPACE  $TEXT$
        .SUBSPA $CODE$
enable_fp_traps
        .PROC
        .EXPORT enable_fp_traps
        .CALLINFO CALLER,FRAME=8
	.ENTER
	LDO     -56(r30),r31
        FSTDS   fr0,0(0,r31)     /* store coprocessor status register    */
	LDWS    0(0,r31),r25     /* load upper status word to r25        */
	DEP     r26,31,5,r25     /* deposit low 5 bits of mask into r25  */
	STWS    r25,0(0,r31)
	FLDDS   0(0,r31),fr0
	.LEAVE
        .PROCEND
        .END