NOEMUL.A 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. (* Release 3.10 *)
  2. (*-------------------------------------------------------------------------*
  3. * *
  4. * NOEMUL.A - hardware-only floating point support *
  5. * *
  6. * COPYRIGHT (C) 1989..1992 Clarion Software Corporation. *
  7. * All Rights Reserved *
  8. * *
  9. *--------------------------------------------------------------------------*)
  10. module noemul
  11. NearCall = 1 - _fcall
  12. SameDS = 1 - _fdata
  13. NearPtr = 1 - _fptr
  14. MThread = _mthread
  15. RegParam = _jpicall
  16. segment EMU_TEXT (EMU_CODE,28H)
  17. segment _BSS(BSS,68H)
  18. ExecFloatState: org 94
  19. select EMU_TEXT
  20. foption 2
  21. ProcessFloat = 14
  22. public __FloatStoreSW :
  23. push bp
  24. mov bp, sp
  25. sub sp, 2
  26. fstsw [bp][-2]
  27. fwait
  28. mov ax, [bp][-2]
  29. mov sp, bp
  30. pop bp
  31. ret far 0
  32. public __FloatStoreCW :
  33. push bp
  34. mov bp, sp
  35. sub sp, 2
  36. fstcw [bp][-2]
  37. fwait
  38. mov ax, [bp][-2]
  39. mov sp, bp
  40. pop bp
  41. ret far 0
  42. public __FloatLoadCW :
  43. push bp
  44. mov bp, sp
  45. sub sp, 2
  46. mov [bp][-2], ax
  47. fwait
  48. fldcw [bp][-2]
  49. mov sp, bp
  50. pop bp
  51. ret far 0
  52. public __FloatExecSave :
  53. push ax
  54. mov ax, _BSS
  55. mov es, ax
  56. fsave es:[ExecFloatState]
  57. pop ax
  58. fwait
  59. ret far 0
  60. public __FloatExecRestore :
  61. push ax
  62. mov ax, _BSS
  63. mov es, ax
  64. frstor es:[ExecFloatState]
  65. pop ax
  66. fwait
  67. ret far 0
  68. public __FloatSave :
  69. fsave es:[ProcessFloat]
  70. fwait
  71. ret far 0
  72. public __FloatRestore :
  73. frstor ds:[ProcessFloat]
  74. fwait
  75. ret far 0
  76. public __FloatFinish:
  77. ret far 0
  78. public __FloatJmpSave :
  79. st1_reg = 20
  80. st2_reg = 30
  81. fld st(0), st(1)
  82. fstp tbyte es:[di][st1_reg], st(0)
  83. fld st(0), st(2)
  84. fstp tbyte es:[di][st2_reg], st(0)
  85. fwait
  86. ret far 0
  87. public __FloatJmpRestore :
  88. fld tbyte st(0), ds:[si][st1_reg]
  89. fstp st(2), st(0)
  90. fld tbyte st(0), ds:[si][st2_reg]
  91. fstp st(3), st(0)
  92. ret far 0
  93. extrn __math_excep
  94. public __FloatMathExcepOs2 :
  95. (* always far called from coresig *)
  96. (*
  97. stack contains far return address to signal handler, then status word,
  98. then far return address to error location, the iret flags.
  99. This is how __math_excep likes it, so just jump there.
  100. *)
  101. fclex
  102. fwait
  103. jmp far __math_excep
  104. public __FloatMathExcepDos :
  105. (*
  106. the stack contains a FAR return address to signal handler, then
  107. the far address of the point of exception, then the iret flags
  108. *)
  109. push ax (* make room for status word *)
  110. push bp
  111. mov bp,sp
  112. push ax
  113. mov ax,[bp][4] (* return ip *)
  114. mov [bp][2],ax
  115. mov ax,[bp][6] (* return cs *)
  116. mov [bp][4],ax
  117. fstsw [bp][6] (* will bring in emulator ! *)
  118. pop ax
  119. pop bp
  120. fclex
  121. jmp far __math_excep
  122. public __FloatInitInstance:
  123. push bp
  124. mov bp, sp
  125. push ax (* dummy *)
  126. finit
  127. fstcw [bp][-2]
  128. fwait
  129. or word [bp][-2] , 0C00H (* round towards zero (chop) *)
  130. and word [bp][-2] ,~001DH (* enable invalid op/underflow/overflow/divide by zero exception *)
  131. fldcw [bp][-2]
  132. extrn __FloatInitStack
  133. call far __FloatInitStack
  134. mov sp,bp
  135. pop bp
  136. ret far 0
  137. public __FloatInit:
  138. extrn __fp_1
  139. call far __fp_1
  140. call far __FloatInitInstance
  141. ret far 0
  142. section
  143. (*emuinit2*)
  144. public FIDRQQ = 0
  145. public FIWRQQ = 0
  146. public FIERQQ = 0
  147. public FIARQQ = 0
  148. public FISRQQ = 0
  149. public FICRQQ = 0
  150. public FJERQQ = 0
  151. public FJARQQ = 0
  152. public FJSRQQ = 0
  153. public FJCRQQ = 0
  154. public FIXRQQ = 0 (* brings this module in - known to linker *)
  155. segment EMU_STATE(DATA,68H)
  156. select EMU_STATE
  157. public emuBuffer :
  158. org 0
  159. end (*NUEMUL.A*)
  160.