WINFLOAT.A 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. (* Release 3.10 *)
  2. (*-------------------------------------------------------------------------*
  3. * *
  4. * WINFLOAT.A - emulator support for Windows *
  5. * *
  6. * COPYRIGHT (C) 1989..1992 Clarion Software Corporation. *
  7. * All Rights Reserved *
  8. * *
  9. *--------------------------------------------------------------------------*)
  10. module winfloat
  11. (*emuinit2*)
  12. public FIDRQQ = 00000H
  13. public FIWRQQ = 00000H
  14. public FIERQQ = 00000H
  15. public FIARQQ = 00000H
  16. public FISRQQ = 00000H
  17. public FICRQQ = 00000H
  18. public FJERQQ = 00000H
  19. public FJARQQ = 00000H
  20. public FJSRQQ = 00000H
  21. public FJCRQQ = 00000H
  22. public FIXRQQ = 0 (* brings this module in - known to linker *)
  23. segment _DATA(DATA,68H)
  24. segment _TEXT(CODE,28H)
  25. extrn __fp_1
  26. extrn __real_in
  27. extrn __real_out
  28. extrn __real_pdef
  29. extrn __real_sdef
  30. extrn __FPMATH
  31. extrn __sigFpWin
  32. ProcessFloat = 14
  33. public __FloatInit:
  34. push ax
  35. push bx
  36. push cx
  37. push dx
  38. xor bx,bx (* __FPMATH sub-function 0 *)
  39. call far __FPMATH (* initialize __FPMATH *)
  40. mov dx, seg __sigFpWin
  41. mov ax,__sigFpWin
  42. mov bx,3 (* __FPMATH sub-function 3 *)
  43. call far __FPMATH (* give __FPMATH float exception handler address *)
  44. call far __fp_1
  45. mov ax,1F22H (* affine,chop,64 bit precision,denorm & precision masked *)
  46. call far __FloatLoadCW (* load jpi standard CW *)
  47. pop dx
  48. pop cx
  49. pop bx
  50. pop ax
  51. ret far 0
  52. public __FloatFinish:
  53. push ax
  54. push bx
  55. push cx
  56. push dx
  57. mov bx, 2 (* __FPMATH sub-function 2 *)
  58. call far __FPMATH
  59. pop dx
  60. pop cx
  61. pop bx
  62. pop ax
  63. ret far 0
  64. public __FloatStoreSW :
  65. push bp
  66. mov bp,sp
  67. push ax
  68. fstsw [bp][-2]
  69. fwait
  70. pop ax
  71. pop bp
  72. ret far 0
  73. public __FloatStoreCW :
  74. push bp
  75. mov bp,sp
  76. push ax
  77. fstcw [bp][-2]
  78. fwait
  79. pop ax
  80. pop bp
  81. ret far 0
  82. public __FloatLoadCW :
  83. push bp
  84. mov bp,sp
  85. push ax
  86. fldcw [bp][-2]
  87. pop ax
  88. pop bp
  89. ret far 0
  90. public __FloatExecSave :
  91. public __FloatExecRestore :
  92. ret far 0
  93. public __FloatSave :
  94. fsave es:[ProcessFloat]
  95. ret far 0
  96. public __FloatRestore :
  97. frstor ds:[ProcessFloat]
  98. ret far 0
  99. public __FloatJmpSave :
  100. st1_reg = 20
  101. st2_reg = 30
  102. fld st(0), st(1)
  103. fstp tbyte es:[di][st1_reg], st(0)
  104. fld st(0), st(2)
  105. fstp tbyte es:[di][st2_reg], st(0)
  106. ret far 0
  107. public __FloatJmpRestore :
  108. fld tbyte st(0), ds:[si][st1_reg]
  109. fstp st(2), st(0)
  110. fld tbyte st(0), ds:[si][st2_reg]
  111. fstp st(3), st(0)
  112. ret far 0
  113. extrn __math_excep
  114. public __FloatMathExcepOs2 :
  115. (* always far called from coresig *)
  116. (*
  117. stack contains far return address to signal handler, then status word,
  118. then far return address to error location, the iret flags.
  119. This is how __math_excep likes it, so just jump there.
  120. *)
  121. fclex
  122. jmp far __math_excep
  123. public __FloatMathExcepDos :
  124. (*
  125. the stack contains a FAR return address to signal handler, then
  126. the far address of the point of exception, then the iret flags
  127. *)
  128. push ax (* make room for status word *)
  129. push bp
  130. mov bp,sp
  131. push ax
  132. mov ax,[bp][4] (* return ip *)
  133. mov [bp][2],ax
  134. mov ax,[bp][6] (* return cs *)
  135. mov [bp][4],ax
  136. fstsw [bp][6] (* will bring in emulator ! *)
  137. pop ax
  138. pop bp
  139. fclex
  140. jmp far __math_excep
  141. end
  142.