1*4882a593Smuzhiyun/* 2*4882a593Smuzhiyun NetWinder Floating Point Emulator 3*4882a593Smuzhiyun (c) Rebel.COM, 1998,1999 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun Direct questions, comments to Scott Bambrough <scottb@netwinder.org> 6*4882a593Smuzhiyun 7*4882a593Smuzhiyun This program is free software; you can redistribute it and/or modify 8*4882a593Smuzhiyun it under the terms of the GNU General Public License as published by 9*4882a593Smuzhiyun the Free Software Foundation; either version 2 of the License, or 10*4882a593Smuzhiyun (at your option) any later version. 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun This program is distributed in the hope that it will be useful, 13*4882a593Smuzhiyun but WITHOUT ANY WARRANTY; without even the implied warranty of 14*4882a593Smuzhiyun MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*4882a593Smuzhiyun GNU General Public License for more details. 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun You should have received a copy of the GNU General Public License 18*4882a593Smuzhiyun along with this program; if not, write to the Free Software 19*4882a593Smuzhiyun Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20*4882a593Smuzhiyun*/ 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun#include "fpa11.h" 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun/* Read and write floating point status register */ 25*4882a593Smuzhiyunstatic inline unsigned int readFPSR(void) 26*4882a593Smuzhiyun{ 27*4882a593Smuzhiyun FPA11 *fpa11 = GET_FPA11(); 28*4882a593Smuzhiyun return (fpa11->fpsr); 29*4882a593Smuzhiyun} 30*4882a593Smuzhiyun 31*4882a593Smuzhiyunstatic inline void writeFPSR(FPSR reg) 32*4882a593Smuzhiyun{ 33*4882a593Smuzhiyun FPA11 *fpa11 = GET_FPA11(); 34*4882a593Smuzhiyun /* the sysid byte in the status register is readonly */ 35*4882a593Smuzhiyun fpa11->fpsr = (fpa11->fpsr & MASK_SYSID) | (reg & ~MASK_SYSID); 36*4882a593Smuzhiyun} 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun/* Read and write floating point control register */ 39*4882a593Smuzhiyunstatic inline FPCR readFPCR(void) 40*4882a593Smuzhiyun{ 41*4882a593Smuzhiyun FPA11 *fpa11 = GET_FPA11(); 42*4882a593Smuzhiyun /* clear SB, AB and DA bits before returning FPCR */ 43*4882a593Smuzhiyun return (fpa11->fpcr & ~MASK_RFC); 44*4882a593Smuzhiyun} 45*4882a593Smuzhiyun 46*4882a593Smuzhiyunstatic inline void writeFPCR(FPCR reg) 47*4882a593Smuzhiyun{ 48*4882a593Smuzhiyun FPA11 *fpa11 = GET_FPA11(); 49*4882a593Smuzhiyun fpa11->fpcr &= ~MASK_WFC; /* clear SB, AB and DA bits */ 50*4882a593Smuzhiyun fpa11->fpcr |= (reg & MASK_WFC); /* write SB, AB and DA bits */ 51*4882a593Smuzhiyun} 52