fpsetround.c revision 1.1
11.1Sjtc/*
21.1Sjtc * Written by J.T. Conklin, Apr 10, 1995
31.1Sjtc * Public domain.
41.1Sjtc */
51.1Sjtc
61.1Sjtc#include <ieeefp.h>
71.1Sjtc
81.1Sjtcfp_rnd
91.1Sjtcfpsetround(rnd_dir)
101.1Sjtc	fp_rnd rnd_dir;
111.1Sjtc{
121.1Sjtc	fp_rnd old;
131.1Sjtc	fp_rnd new;
141.1Sjtc
151.1Sjtc	__asm__("st %%fsr,%0" : "=m" (*&old));
161.1Sjtc
171.1Sjtc	new = old;
181.1Sjtc	new &= ~(0x03 << 30);
191.1Sjtc	new |= ((rnd_dir & 0x03) << 30);
201.1Sjtc
211.1Sjtc	__asm__("ld %0,%%fsr" : : "m" (*&new));
221.1Sjtc
231.1Sjtc	return (old >> 30) & 0x03;
241.1Sjtc}
25