fpsetround.c revision 1.2
11.2Sperry/*	$NetBSD: fpsetround.c,v 1.2 1998/01/09 03:15:18 perry Exp $	*/
21.2Sperry
31.1Sjtc/*
41.1Sjtc * Written by J.T. Conklin, Apr 10, 1995
51.1Sjtc * Public domain.
61.1Sjtc */
71.1Sjtc
81.1Sjtc#include <ieeefp.h>
91.1Sjtc
101.1Sjtcfp_rnd
111.1Sjtcfpsetround(rnd_dir)
121.1Sjtc	fp_rnd rnd_dir;
131.1Sjtc{
141.1Sjtc	fp_rnd old;
151.1Sjtc	fp_rnd new;
161.1Sjtc
171.1Sjtc	__asm__("st %%fsr,%0" : "=m" (*&old));
181.1Sjtc
191.1Sjtc	new = old;
201.1Sjtc	new &= ~(0x03 << 30);
211.1Sjtc	new |= ((rnd_dir & 0x03) << 30);
221.1Sjtc
231.1Sjtc	__asm__("ld %0,%%fsr" : : "m" (*&new));
241.1Sjtc
251.1Sjtc	return (old >> 30) & 0x03;
261.1Sjtc}
27