18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/*---------------------------------------------------------------------------+ 38c2ecf20Sopenharmony_ci | fpu_arith.c | 48c2ecf20Sopenharmony_ci | | 58c2ecf20Sopenharmony_ci | Code to implement the FPU register/register arithmetic instructions | 68c2ecf20Sopenharmony_ci | | 78c2ecf20Sopenharmony_ci | Copyright (C) 1992,1993,1997 | 88c2ecf20Sopenharmony_ci | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia | 98c2ecf20Sopenharmony_ci | E-mail billm@suburbia.net | 108c2ecf20Sopenharmony_ci | | 118c2ecf20Sopenharmony_ci | | 128c2ecf20Sopenharmony_ci +---------------------------------------------------------------------------*/ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include "fpu_system.h" 158c2ecf20Sopenharmony_ci#include "fpu_emu.h" 168c2ecf20Sopenharmony_ci#include "control_w.h" 178c2ecf20Sopenharmony_ci#include "status_w.h" 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_civoid fadd__(void) 208c2ecf20Sopenharmony_ci{ 218c2ecf20Sopenharmony_ci /* fadd st,st(i) */ 228c2ecf20Sopenharmony_ci int i = FPU_rm; 238c2ecf20Sopenharmony_ci clear_C1(); 248c2ecf20Sopenharmony_ci FPU_add(&st(i), FPU_gettagi(i), 0, control_word); 258c2ecf20Sopenharmony_ci} 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_civoid fmul__(void) 288c2ecf20Sopenharmony_ci{ 298c2ecf20Sopenharmony_ci /* fmul st,st(i) */ 308c2ecf20Sopenharmony_ci int i = FPU_rm; 318c2ecf20Sopenharmony_ci clear_C1(); 328c2ecf20Sopenharmony_ci FPU_mul(&st(i), FPU_gettagi(i), 0, control_word); 338c2ecf20Sopenharmony_ci} 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_civoid fsub__(void) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci /* fsub st,st(i) */ 388c2ecf20Sopenharmony_ci clear_C1(); 398c2ecf20Sopenharmony_ci FPU_sub(0, FPU_rm, control_word); 408c2ecf20Sopenharmony_ci} 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_civoid fsubr_(void) 438c2ecf20Sopenharmony_ci{ 448c2ecf20Sopenharmony_ci /* fsubr st,st(i) */ 458c2ecf20Sopenharmony_ci clear_C1(); 468c2ecf20Sopenharmony_ci FPU_sub(REV, FPU_rm, control_word); 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_civoid fdiv__(void) 508c2ecf20Sopenharmony_ci{ 518c2ecf20Sopenharmony_ci /* fdiv st,st(i) */ 528c2ecf20Sopenharmony_ci clear_C1(); 538c2ecf20Sopenharmony_ci FPU_div(0, FPU_rm, control_word); 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_civoid fdivr_(void) 578c2ecf20Sopenharmony_ci{ 588c2ecf20Sopenharmony_ci /* fdivr st,st(i) */ 598c2ecf20Sopenharmony_ci clear_C1(); 608c2ecf20Sopenharmony_ci FPU_div(REV, FPU_rm, control_word); 618c2ecf20Sopenharmony_ci} 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_civoid fadd_i(void) 648c2ecf20Sopenharmony_ci{ 658c2ecf20Sopenharmony_ci /* fadd st(i),st */ 668c2ecf20Sopenharmony_ci int i = FPU_rm; 678c2ecf20Sopenharmony_ci clear_C1(); 688c2ecf20Sopenharmony_ci FPU_add(&st(i), FPU_gettagi(i), i, control_word); 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_civoid fmul_i(void) 728c2ecf20Sopenharmony_ci{ 738c2ecf20Sopenharmony_ci /* fmul st(i),st */ 748c2ecf20Sopenharmony_ci clear_C1(); 758c2ecf20Sopenharmony_ci FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word); 768c2ecf20Sopenharmony_ci} 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_civoid fsubri(void) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci /* fsubr st(i),st */ 818c2ecf20Sopenharmony_ci clear_C1(); 828c2ecf20Sopenharmony_ci FPU_sub(DEST_RM, FPU_rm, control_word); 838c2ecf20Sopenharmony_ci} 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_civoid fsub_i(void) 868c2ecf20Sopenharmony_ci{ 878c2ecf20Sopenharmony_ci /* fsub st(i),st */ 888c2ecf20Sopenharmony_ci clear_C1(); 898c2ecf20Sopenharmony_ci FPU_sub(REV | DEST_RM, FPU_rm, control_word); 908c2ecf20Sopenharmony_ci} 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_civoid fdivri(void) 938c2ecf20Sopenharmony_ci{ 948c2ecf20Sopenharmony_ci /* fdivr st(i),st */ 958c2ecf20Sopenharmony_ci clear_C1(); 968c2ecf20Sopenharmony_ci FPU_div(DEST_RM, FPU_rm, control_word); 978c2ecf20Sopenharmony_ci} 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_civoid fdiv_i(void) 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci /* fdiv st(i),st */ 1028c2ecf20Sopenharmony_ci clear_C1(); 1038c2ecf20Sopenharmony_ci FPU_div(REV | DEST_RM, FPU_rm, control_word); 1048c2ecf20Sopenharmony_ci} 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_civoid faddp_(void) 1078c2ecf20Sopenharmony_ci{ 1088c2ecf20Sopenharmony_ci /* faddp st(i),st */ 1098c2ecf20Sopenharmony_ci int i = FPU_rm; 1108c2ecf20Sopenharmony_ci clear_C1(); 1118c2ecf20Sopenharmony_ci if (FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0) 1128c2ecf20Sopenharmony_ci FPU_pop(); 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_civoid fmulp_(void) 1168c2ecf20Sopenharmony_ci{ 1178c2ecf20Sopenharmony_ci /* fmulp st(i),st */ 1188c2ecf20Sopenharmony_ci clear_C1(); 1198c2ecf20Sopenharmony_ci if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0) 1208c2ecf20Sopenharmony_ci FPU_pop(); 1218c2ecf20Sopenharmony_ci} 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_civoid fsubrp(void) 1248c2ecf20Sopenharmony_ci{ 1258c2ecf20Sopenharmony_ci /* fsubrp st(i),st */ 1268c2ecf20Sopenharmony_ci clear_C1(); 1278c2ecf20Sopenharmony_ci if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0) 1288c2ecf20Sopenharmony_ci FPU_pop(); 1298c2ecf20Sopenharmony_ci} 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_civoid fsubp_(void) 1328c2ecf20Sopenharmony_ci{ 1338c2ecf20Sopenharmony_ci /* fsubp st(i),st */ 1348c2ecf20Sopenharmony_ci clear_C1(); 1358c2ecf20Sopenharmony_ci if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0) 1368c2ecf20Sopenharmony_ci FPU_pop(); 1378c2ecf20Sopenharmony_ci} 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_civoid fdivrp(void) 1408c2ecf20Sopenharmony_ci{ 1418c2ecf20Sopenharmony_ci /* fdivrp st(i),st */ 1428c2ecf20Sopenharmony_ci clear_C1(); 1438c2ecf20Sopenharmony_ci if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0) 1448c2ecf20Sopenharmony_ci FPU_pop(); 1458c2ecf20Sopenharmony_ci} 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_civoid fdivp_(void) 1488c2ecf20Sopenharmony_ci{ 1498c2ecf20Sopenharmony_ci /* fdivp st(i),st */ 1508c2ecf20Sopenharmony_ci clear_C1(); 1518c2ecf20Sopenharmony_ci if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0) 1528c2ecf20Sopenharmony_ci FPU_pop(); 1538c2ecf20Sopenharmony_ci} 154