fpu_arith.c (3045B)
1// SPDX-License-Identifier: GPL-2.0 2/*---------------------------------------------------------------------------+ 3 | fpu_arith.c | 4 | | 5 | Code to implement the FPU register/register arithmetic instructions | 6 | | 7 | Copyright (C) 1992,1993,1997 | 8 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia | 9 | E-mail billm@suburbia.net | 10 | | 11 | | 12 +---------------------------------------------------------------------------*/ 13 14#include "fpu_system.h" 15#include "fpu_emu.h" 16#include "control_w.h" 17#include "status_w.h" 18 19void fadd__(void) 20{ 21 /* fadd st,st(i) */ 22 int i = FPU_rm; 23 clear_C1(); 24 FPU_add(&st(i), FPU_gettagi(i), 0, control_word); 25} 26 27void fmul__(void) 28{ 29 /* fmul st,st(i) */ 30 int i = FPU_rm; 31 clear_C1(); 32 FPU_mul(&st(i), FPU_gettagi(i), 0, control_word); 33} 34 35void fsub__(void) 36{ 37 /* fsub st,st(i) */ 38 clear_C1(); 39 FPU_sub(0, FPU_rm, control_word); 40} 41 42void fsubr_(void) 43{ 44 /* fsubr st,st(i) */ 45 clear_C1(); 46 FPU_sub(REV, FPU_rm, control_word); 47} 48 49void fdiv__(void) 50{ 51 /* fdiv st,st(i) */ 52 clear_C1(); 53 FPU_div(0, FPU_rm, control_word); 54} 55 56void fdivr_(void) 57{ 58 /* fdivr st,st(i) */ 59 clear_C1(); 60 FPU_div(REV, FPU_rm, control_word); 61} 62 63void fadd_i(void) 64{ 65 /* fadd st(i),st */ 66 int i = FPU_rm; 67 clear_C1(); 68 FPU_add(&st(i), FPU_gettagi(i), i, control_word); 69} 70 71void fmul_i(void) 72{ 73 /* fmul st(i),st */ 74 clear_C1(); 75 FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word); 76} 77 78void fsubri(void) 79{ 80 /* fsubr st(i),st */ 81 clear_C1(); 82 FPU_sub(DEST_RM, FPU_rm, control_word); 83} 84 85void fsub_i(void) 86{ 87 /* fsub st(i),st */ 88 clear_C1(); 89 FPU_sub(REV | DEST_RM, FPU_rm, control_word); 90} 91 92void fdivri(void) 93{ 94 /* fdivr st(i),st */ 95 clear_C1(); 96 FPU_div(DEST_RM, FPU_rm, control_word); 97} 98 99void fdiv_i(void) 100{ 101 /* fdiv st(i),st */ 102 clear_C1(); 103 FPU_div(REV | DEST_RM, FPU_rm, control_word); 104} 105 106void faddp_(void) 107{ 108 /* faddp st(i),st */ 109 int i = FPU_rm; 110 clear_C1(); 111 if (FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0) 112 FPU_pop(); 113} 114 115void fmulp_(void) 116{ 117 /* fmulp st(i),st */ 118 clear_C1(); 119 if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0) 120 FPU_pop(); 121} 122 123void fsubrp(void) 124{ 125 /* fsubrp st(i),st */ 126 clear_C1(); 127 if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0) 128 FPU_pop(); 129} 130 131void fsubp_(void) 132{ 133 /* fsubp st(i),st */ 134 clear_C1(); 135 if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0) 136 FPU_pop(); 137} 138 139void fdivrp(void) 140{ 141 /* fdivrp st(i),st */ 142 clear_C1(); 143 if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0) 144 FPU_pop(); 145} 146 147void fdivp_(void) 148{ 149 /* fdivp st(i),st */ 150 clear_C1(); 151 if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0) 152 FPU_pop(); 153}