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.

174 lines
3.3 KiB

  1. page ,132
  2. subttl emlsquad.asm - Load/Store 64-bit integers
  3. ;***
  4. ;emlsquad.asm - Load/Store 64-bit integers
  5. ;
  6. ; Copyright (c) 1986-89, Microsoft Corporation
  7. ;
  8. ;Purpose:
  9. ; Load/Store 64-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 Quad (64 Bit) Integer ;
  21. ; ;
  22. ;*********************************************************************;
  23. ;
  24. ; ES:SI: memory address of 64 bit integer
  25. ProfBegin LSQUAD
  26. pub eFLDlongint
  27. LDUS2AX ; Fetch the integer
  28. MOV DX,AX ; into DI:BP:BX:DX
  29. LDUS2AX
  30. MOV BX,AX
  31. LDUS2AX
  32. MOV BP,AX
  33. LDUS2AX
  34. MOV DI,AX
  35. OR AX,BP
  36. OR AX,BX
  37. OR AX,DX
  38. JZ short Jmp2LoadZero
  39. MOV AX,63 ; Exponent would be 63 if no shifts needed
  40. PUSHST ; Get a new TOS
  41. XOR CL,CL
  42. MOV Tag[esi],CL ; Tag number as valid non-zero
  43. MOV CX,DI ; Sign of Integer to CH
  44. AND CH,Sign
  45. JNS short SETFLAG64 ; If positive integer set the flag
  46. call TwosComplement64; Otherwise complement the number first
  47. pub SETFLAG64
  48. MOV Flag[esi],CH
  49. OR DI,DI
  50. JNZ Jmp2IntegerToInternal
  51. OR BP,BP
  52. JNZ Jmp2IntegerToInternal
  53. pub SPEEDSHIFT64
  54. MOV DI,BX
  55. MOV BP,DX
  56. XOR BX,BX
  57. XOR DX,DX
  58. SUB AX,32
  59. Jmp2IntegerToInternal:
  60. JMP IntegerToInternal
  61. Jmp2LoadZero:
  62. JMP LoadZero
  63. page
  64. ;*********************************************************************;
  65. ; ;
  66. ; Store Quad (64 Bit) Integer ;
  67. ; ;
  68. ;*********************************************************************;
  69. ;
  70. ; ES:SI: memory address of 64 bit integer
  71. pub eFSTlongint
  72. PUSH esi
  73. call TOSto64int ; convert TOS to 64-bit integer
  74. ; in DI:BP:BX:DX
  75. XCHG AX,DI
  76. XCHG AX,DX ; now in DX:BP:BX:AX
  77. POP edi ; Restore Memory address
  78. STAX2US
  79. MOV AX,BX
  80. STAX2US
  81. MOV AX,BP
  82. STAX2US
  83. MOV AX,DX
  84. STAX2US
  85. RET
  86. pub TOSto64int
  87. MOV esi,[CURstk]
  88. ; Test for special conditions
  89. TEST byte ptr Tag[esi],Special ; If number is not in range it is overflow
  90. JNZ short IntegerOverflow64
  91. TEST byte ptr Tag[esi],ZROorINF
  92. JNZ short StoreIntegerZero64
  93. ; Fetch Exponent & test fo blatent overflow
  94. MOV CX,Expon[esi]
  95. CMP CX,63
  96. JG short IntegerOverflow64
  97. if fastSP
  98. ;UNDONE - ????
  99. else
  100. MOV BP,MB4[esi] ; Fetch mantissa to DI:BP:BX:DX
  101. MOV DI,MB6[esi]
  102. MOV DX,MB0[esi]
  103. MOV BX,MB2[esi]
  104. endif
  105. CALL InternalToInteger
  106. ; Integer in DI:BP:BX:DX
  107. ; (not yet 2's complement)
  108. MOV AH,Flag[esi] ; See if we need to complement
  109. OR AH,AH
  110. JNS short Int64in2sComp
  111. call TwosComplement64
  112. pub Int64in2sComp
  113. XOR AX,DI ; If Signs agree we did not overflow
  114. JS short IntOverOrZero64 ; Special case is -0 which we let pass
  115. pub Store64
  116. POPSTsi ; store POP to long-integer
  117. ret
  118. if fastSP
  119. ;UNDONE ???
  120. endif
  121. pub StoreIntegerZero64
  122. XOR DI,DI
  123. pub ZeroLower48
  124. XOR BP,BP
  125. MOV BX,BP
  126. MOV DX,BP
  127. JMP Store64
  128. pub IntOverOrZero64
  129. OR DI,BP
  130. OR DI,BX
  131. OR DI,DX
  132. JNZ IntegerOverflow64
  133. JMP Store64 ; Return zero
  134. pub IntegerOverflow64
  135. OR CURerr,Invalid
  136. MOV DI,8000H ; Integer Indefinite
  137. JMP short ZeroLower48
  138. pub TwosComplement64
  139. NOT DI ; 2's Complement of DI:BP:BX:DX
  140. NOT BP
  141. NOT BX
  142. NEG DX
  143. CMC
  144. ADC BX,0
  145. ADC BP,0
  146. ADC DI,0
  147. ret
  148. ProfEnd LSQUAD