Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

284 lines
5.7 KiB

  1. page ,132
  2. subttl emlsint.asm - Load/Store 16/32-bit integers
  3. ;***
  4. ;emlsint.asm - Load/Store 16/32-bit integers
  5. ;
  6. ; Copyright (c) 1986-89, Microsoft Corporation
  7. ;
  8. ;Purpose:
  9. ; Load/Store 16/32-bit integers
  10. ;
  11. ; This Module contains Proprietary Information of Microsoft
  12. ; Corporation and should be treated as Confidential.
  13. ;
  14. ;Revision History:
  15. ; See emulator.hst
  16. ;
  17. ;*******************************************************************************
  18. ;*********************************************************************;
  19. ; ;
  20. ; Load Single (16 Bit) Integer ;
  21. ; ;
  22. ;*********************************************************************;
  23. ; ES:SI: memory address of 16 bit integer
  24. ProfBegin LSINT
  25. pub eFLDsi
  26. LDUS2AX ; Fetch the integer
  27. MOV DI,AX ; into DI:BP:BX:DX
  28. OR DI,DI
  29. JZ short LoadZero
  30. XOR BP,BP
  31. MOV BX,BP
  32. MOV DX,BX
  33. MOV AX,15 ; Exponent would be 15 if no shifts needed
  34. PUSHST ; Get a new TOS
  35. XOR CL,CL
  36. MOV Tag[esi],CL ; Tag number as valid non-zero
  37. MOV CX,DI ; Sign of Integer to CH
  38. AND CH,Sign
  39. if fastSP
  40. OR CH,Single
  41. endif
  42. JNS short SETFLAG16 ; If positive integer set the flag
  43. NEG DI ; Otherwise compliment the number first
  44. pub SETFLAG16
  45. MOV Flag[esi],CH
  46. JMP IntegerToInternal
  47. pub LoadZero
  48. PUSHST ; Get a new TOS
  49. XOR AX,AX
  50. MOV MB0[esi],AX
  51. MOV MB2[esi],AX
  52. MOV MB4[esi],AX
  53. MOV MB6[esi],AX
  54. MOV Expon[esi],IexpMin - IexpBias
  55. MOV Flag[esi],AH
  56. MOV AH,ZROorINF
  57. MOV Tag[esi],AH
  58. RET
  59. PAGE
  60. ;*********************************************************************;
  61. ; ;
  62. ; Store Single (16 Bit) Integer ;
  63. ; ;
  64. ;*********************************************************************;
  65. ;
  66. ; ES:SI: memory address of 16 bit integer
  67. pub eFSTsi
  68. PUSH esi ; Save memory address for store
  69. MOV esi,[CURstk]
  70. ; Test for special conditions
  71. TEST byte ptr Tag[esi],Special ; If number is not in range it is overflow
  72. JNZ short IntegerOverflow16
  73. TEST byte ptr Tag[esi],ZROorINF
  74. JNZ short StoreIntegerZero16
  75. ; Fetch Exponent & test fo blatent overflow
  76. MOV CX,Expon[esi]
  77. CMP CX,15
  78. JG short IntegerOverflow16
  79. if fastSP
  80. MOV BX,MB4[esi] ; Fetch mantissa to DI:BP:BX:DX
  81. MOV DI,MB6[esi]
  82. TEST byte ptr Flag[esi],Single
  83. JZ SSID
  84. XOR BL,BL
  85. MOV BP,BX
  86. XOR BX,BX
  87. MOV DX,BX
  88. SSI:
  89. else
  90. MOV BP,MB4[esi] ; Fetch mantissa to DI:BP:BX:DX
  91. MOV DI,MB6[esi]
  92. MOV DX,MB0[esi]
  93. MOV BX,MB2[esi]
  94. endif
  95. CALL InternalToInteger
  96. ; Integer now in BX:DX (not yet 2's compliment)
  97. OR BX,BX ; Test again for Overflow
  98. JNZ short IntegerOverflow16
  99. MOV AH,Flag[esi] ; See if we need to compliment
  100. OR AH,AH
  101. JNS short Int16in2sComp
  102. NEG DX
  103. JZ short Store16 ; Special case 0
  104. pub Int16in2sComp
  105. XOR AX,DX ; If Signs agree we did not overflow
  106. JS short IntegerOverflow16
  107. pub Store16
  108. POP edi ; Restore Memory address
  109. MOV AX,DX
  110. STAX2US
  111. RET
  112. if fastSP
  113. SSID:
  114. MOV BP,BX
  115. MOV DX,MB0[esi]
  116. MOV BX,MB2[esi]
  117. JMP SSI
  118. endif
  119. pub StoreIntegerZero16
  120. XOR DX,DX
  121. JMP Store16
  122. pub IntegerOverflow16
  123. OR [CURerr],Invalid
  124. MOV DX,8000H ; Integer Indefinite
  125. JMP Store16
  126. page
  127. ;*********************************************************************;
  128. ; ;
  129. ; Load Double (32 Bit) Integer ;
  130. ; ;
  131. ;*********************************************************************;
  132. ;
  133. ; ES:SI: memory address of 32 bit integer
  134. pub eFLDdi
  135. LDUS2AX ; Fetch the integer
  136. MOV BP,AX ; into DI:BP:BX:DX
  137. LDUS2AX
  138. MOV DI,AX
  139. OR AX,BP
  140. JZ short JMPLoadZeroBecauseThisLanguageHasNoFarConditionalJump
  141. XOR BX,BX
  142. MOV DX,BX
  143. MOV AX,31 ; Exponent would be 31 if no shifts needed
  144. PUSHST ; Get a new TOS
  145. XOR CL,CL
  146. MOV Tag[esi],CL ; Tag number as valid non-zero
  147. MOV CX,DI ; Sign of Integer to CH
  148. AND CH,Sign
  149. JNS short SETFLAG32 ; If positive integer set the flag
  150. XOR DI,0FFFFH ; Otherwise compliment the number first
  151. XOR BP,0FFFFH
  152. ADD BP,1
  153. ADC DI,0
  154. pub SETFLAG32
  155. MOV Flag[esi],CH
  156. OR DI,DI
  157. JZ short SPEEDSHIFT32
  158. JMP IntegerToInternal
  159. JMPLoadZeroBecauseThisLanguageHasNoFarConditionalJump:
  160. JMP LoadZero
  161. pub SPEEDSHIFT32
  162. MOV DI,BP
  163. XOR BP,BP
  164. SUB AX,16
  165. JMP IntegerToInternal
  166. page
  167. ;*********************************************************************;
  168. ; ;
  169. ; Store Double (32 Bit) Integer ;
  170. ; ;
  171. ;*********************************************************************;
  172. ;
  173. ; ES:SI: memory address of 32 bit integer
  174. pub eFSTdi
  175. PUSH esi
  176. call TOSto32int ; convert TOS to 32-bit integer
  177. POP edi ; Restore Memory address
  178. MOV AX,DX
  179. STAX2US
  180. MOV AX,BX
  181. STAX2US
  182. RET
  183. pub TOSto32int
  184. MOV esi,[CURstk]
  185. ; Test for special conditions
  186. TEST byte ptr Tag[esi],Special ; If number is not in range it is overflow
  187. JNZ short IntegerOverflow32
  188. TEST byte ptr Tag[esi],ZROorINF
  189. JNZ short StoreIntegerZero32
  190. ; Fetch Exponent & test fo blatent overflow
  191. MOV CX,Expon[esi]
  192. CMP CX,31
  193. JG short IntegerOverflow32
  194. if fastSP
  195. MOV BX,MB4[esi] ; Fetch mantissa to DI:BP:BX:DX
  196. MOV DI,MB6[esi]
  197. TEST byte ptr Flag[esi],Single
  198. JZ SDID
  199. XOR BL,BL
  200. MOV BP,BX
  201. XOR BX,BX
  202. MOV DX,BX
  203. SDI:
  204. else
  205. MOV BP,MB4[esi] ; Fetch mantissa to DI:BP:BX:DX
  206. MOV DI,MB6[esi]
  207. MOV DX,MB0[esi]
  208. MOV BX,MB2[esi]
  209. endif
  210. CALL InternalToInteger
  211. ; Integer in BP:BX:DX (not yet 2's compliment)
  212. OR BP,BP ; Test again for Overflow
  213. JNZ short IntegerOverflow32
  214. MOV AH,Flag[esi] ; See if we need to compliment
  215. OR AH,AH
  216. JNS short Int32in2sComp
  217. XOR BX,0FFFFH ; 2's Compliment of BX:DX
  218. XOR DX,0FFFFH
  219. ADD DX,1
  220. ADC BX,0
  221. pub Int32in2sComp
  222. XOR AX,BX ; If Signs agree we did not overflow
  223. JS short IntOverOrZero32 ; Special case is -0 which we let pass
  224. pub Store32
  225. ret
  226. if fastSP
  227. SDID:
  228. MOV BP,BX
  229. MOV DX,MB0[esi]
  230. MOV BX,MB2[esi]
  231. JMP SDI
  232. endif
  233. pub StoreIntegerZero32
  234. XOR DX,DX
  235. MOV BX,DX
  236. ret
  237. pub IntOverOrZero32
  238. OR BX,DX
  239. JZ Store32
  240. pub IntegerOverflow32
  241. OR CURerr,Invalid
  242. MOV BX,8000H ; Integer Indefinite
  243. XOR DX,DX
  244. ret
  245. ProfEnd LSINT