--- nono/fpe/fpu_emulate.c 2026/04/29 17:05:23 1.1.1.3 +++ nono/fpe/fpu_emulate.c 2026/04/29 17:05:31 1.1.1.5 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.c,v 1.40 2019/12/27 07:41:23 msaitoh Exp $ */ +/* $NetBSD: fpu_emulate.c,v 1.41 2023/09/17 13:14:08 andvar Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -123,12 +123,12 @@ fpu_emulate(struct frame *frame, struct if ((sval & 0xf000) != 0xf000) { DPRINTF(("%s: not coproc. insn.: opcode=0x%x\n", - __func__, word)); + __func__, sval)); fpe_abort(frame, ksi, SIGILL, ILL_ILLOPC); } if ((sval & 0x0E00) != 0x0200) { - DPRINTF(("%s: bad coproc. id: opcode=0x%x\n", __func__, word)); + DPRINTF(("%s: bad coproc. id: opcode=0x%x\n", __func__, sval)); fpe_abort(frame, ksi, SIGILL, ILL_ILLOPC); } @@ -948,7 +948,6 @@ test_cc(struct fpemu *fe, int pred) int fpsr; fpsr = fe->fe_fpsr; - fpsr &= ~FPSR_EXCP; /* clear all exceptions */ DPRINTF(("%s: fpsr=0x%08x\n", __func__, fpsr)); pred &= 0x3f; /* lowest 6 bits */ @@ -1022,6 +1021,10 @@ test_cc(struct fpemu *fe, int pred) if (sig_bsun && (fpsr & FPSR_NAN)) { fpsr |= FPSR_BSUN; } + /* if BSUN is set, IOP is set */ + if ((fpsr & FPSR_BSUN)) { + fpsr |= FPSR_AIOP; + } /* put fpsr back */ fe->fe_fpframe->fpf_fpsr = fe->fe_fpsr = fpsr; @@ -1192,3 +1195,23 @@ fpu_emul_brcc(struct fpemu *fe, struct i return 0; } #endif /* !XM6i_FPE */ + +#if defined(XM6i_FPE) +// fpn のタグ情報のうち、ゼロ、Inf、NAN、それ以外(ここでは正規化数)を返す。 +// 非正規化数とアンノーマル数はここに来る前に弾いてある。 +// 68040 の FSAVE で使う。 +int +fpu_gettag(const struct fpn *fpn) +{ + if (ISZERO(fpn)) { + return 1; + } + if (ISINF(fpn)) { + return 2; + } + if (ISNAN(fpn)) { + return 3; + } + return 0; +} +#endif