fpu_arith.c 2.9 KB

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