162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci    NetWinder Floating Point Emulator
362306a36Sopenharmony_ci    (c) Rebel.COM, 1998,1999
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci    Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci    This program is free software; you can redistribute it and/or modify
862306a36Sopenharmony_ci    it under the terms of the GNU General Public License as published by
962306a36Sopenharmony_ci    the Free Software Foundation; either version 2 of the License, or
1062306a36Sopenharmony_ci    (at your option) any later version.
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci    This program is distributed in the hope that it will be useful,
1362306a36Sopenharmony_ci    but WITHOUT ANY WARRANTY; without even the implied warranty of
1462306a36Sopenharmony_ci    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1562306a36Sopenharmony_ci    GNU General Public License for more details.
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci    You should have received a copy of the GNU General Public License
1862306a36Sopenharmony_ci    along with this program; if not, write to the Free Software
1962306a36Sopenharmony_ci    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2062306a36Sopenharmony_ci*/
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#include "fpa11.h"
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/* Read and write floating point status register */
2562306a36Sopenharmony_cistatic inline unsigned int readFPSR(void)
2662306a36Sopenharmony_ci{
2762306a36Sopenharmony_ci	FPA11 *fpa11 = GET_FPA11();
2862306a36Sopenharmony_ci	return (fpa11->fpsr);
2962306a36Sopenharmony_ci}
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_cistatic inline void writeFPSR(FPSR reg)
3262306a36Sopenharmony_ci{
3362306a36Sopenharmony_ci	FPA11 *fpa11 = GET_FPA11();
3462306a36Sopenharmony_ci	/* the sysid byte in the status register is readonly */
3562306a36Sopenharmony_ci	fpa11->fpsr = (fpa11->fpsr & MASK_SYSID) | (reg & ~MASK_SYSID);
3662306a36Sopenharmony_ci}
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/* Read and write floating point control register */
3962306a36Sopenharmony_cistatic inline FPCR readFPCR(void)
4062306a36Sopenharmony_ci{
4162306a36Sopenharmony_ci	FPA11 *fpa11 = GET_FPA11();
4262306a36Sopenharmony_ci	/* clear SB, AB and DA bits before returning FPCR */
4362306a36Sopenharmony_ci	return (fpa11->fpcr & ~MASK_RFC);
4462306a36Sopenharmony_ci}
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_cistatic inline void writeFPCR(FPCR reg)
4762306a36Sopenharmony_ci{
4862306a36Sopenharmony_ci	FPA11 *fpa11 = GET_FPA11();
4962306a36Sopenharmony_ci	fpa11->fpcr &= ~MASK_WFC;		/* clear SB, AB and DA bits */
5062306a36Sopenharmony_ci	fpa11->fpcr |= (reg & MASK_WFC);	/* write SB, AB and DA bits */
5162306a36Sopenharmony_ci}
52