18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci    NetWinder Floating Point Emulator
38c2ecf20Sopenharmony_ci    (c) Rebel.COM, 1998,1999
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci    Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci    This program is free software; you can redistribute it and/or modify
88c2ecf20Sopenharmony_ci    it under the terms of the GNU General Public License as published by
98c2ecf20Sopenharmony_ci    the Free Software Foundation; either version 2 of the License, or
108c2ecf20Sopenharmony_ci    (at your option) any later version.
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci    This program is distributed in the hope that it will be useful,
138c2ecf20Sopenharmony_ci    but WITHOUT ANY WARRANTY; without even the implied warranty of
148c2ecf20Sopenharmony_ci    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
158c2ecf20Sopenharmony_ci    GNU General Public License for more details.
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci    You should have received a copy of the GNU General Public License
188c2ecf20Sopenharmony_ci    along with this program; if not, write to the Free Software
198c2ecf20Sopenharmony_ci    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
208c2ecf20Sopenharmony_ci*/
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#include "fpa11.h"
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* Read and write floating point status register */
258c2ecf20Sopenharmony_cistatic inline unsigned int readFPSR(void)
268c2ecf20Sopenharmony_ci{
278c2ecf20Sopenharmony_ci	FPA11 *fpa11 = GET_FPA11();
288c2ecf20Sopenharmony_ci	return (fpa11->fpsr);
298c2ecf20Sopenharmony_ci}
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistatic inline void writeFPSR(FPSR reg)
328c2ecf20Sopenharmony_ci{
338c2ecf20Sopenharmony_ci	FPA11 *fpa11 = GET_FPA11();
348c2ecf20Sopenharmony_ci	/* the sysid byte in the status register is readonly */
358c2ecf20Sopenharmony_ci	fpa11->fpsr = (fpa11->fpsr & MASK_SYSID) | (reg & ~MASK_SYSID);
368c2ecf20Sopenharmony_ci}
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/* Read and write floating point control register */
398c2ecf20Sopenharmony_cistatic inline FPCR readFPCR(void)
408c2ecf20Sopenharmony_ci{
418c2ecf20Sopenharmony_ci	FPA11 *fpa11 = GET_FPA11();
428c2ecf20Sopenharmony_ci	/* clear SB, AB and DA bits before returning FPCR */
438c2ecf20Sopenharmony_ci	return (fpa11->fpcr & ~MASK_RFC);
448c2ecf20Sopenharmony_ci}
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_cistatic inline void writeFPCR(FPCR reg)
478c2ecf20Sopenharmony_ci{
488c2ecf20Sopenharmony_ci	FPA11 *fpa11 = GET_FPA11();
498c2ecf20Sopenharmony_ci	fpa11->fpcr &= ~MASK_WFC;		/* clear SB, AB and DA bits */
508c2ecf20Sopenharmony_ci	fpa11->fpcr |= (reg & MASK_WFC);	/* write SB, AB and DA bits */
518c2ecf20Sopenharmony_ci}
52