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.

197 lines
4.1 KiB

  1. page ,132
  2. subttl emfcom.asm - Comparison instructions
  3. ;***
  4. ;emfcom.asm - Comparison instructions
  5. ;
  6. ; Copyright (c) 1986-89, Microsoft Corporation
  7. ;
  8. ;Purpose:
  9. ; Comparison instructions
  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. ; Comparison instructions: FCOM,FCOMP,FCOMPP,FTST,FXAM ;
  21. ; ;
  22. ;*********************************************************************;
  23. ProfBegin FCOM
  24. pub eFCOMP
  25. MOV DX,1 ; Counts number of POPs needed (0 or 1)
  26. JMP short CommonCOM
  27. pub eFCOM
  28. XOR DX,DX ; No extra POP needed at end
  29. pub CommonCOM ; SI points to ST, DI points to source
  30. TEST WORD PTR [CURerr],MemoryOperand
  31. JZ short ComSIandDIset
  32. XCHG esi,edi ; Switch SI, DI for memory operands
  33. pub ComSIandDIset
  34. MOV AL,Flag[esi] ; All comparisons are ST ? source
  35. MOV AH,Flag[edi] ; Fetch signs
  36. XOR ebx,ebx
  37. MOV BL,Tag[esi]
  38. SHL BL,1
  39. SHL BL,1
  40. OR BL,Tag[edi]
  41. ifdef i386
  42. JMP COMtab[4*ebx]
  43. else
  44. SHL BL,1
  45. JMP COMtab[ebx]
  46. endif
  47. pub COMvalidvalid
  48. if fastSP
  49. MOV BX,AX ; Keep copy of the Single Flags
  50. endif
  51. XOR AH,AL ; Are signs different?
  52. JS short COMsignSI ; if so then sign of SI will determine
  53. OR AL,AL ; else signs are same. See if negative
  54. JNS short CompareExponents ; If negative then reverse sense of compare
  55. XCHG esi,edi ; by swapping the arguments
  56. XCHG BL,BH ; Swap single flags
  57. pub CompareExponents
  58. MOV AX,Expon[esi]
  59. CMP AX,Expon[edi]
  60. JL short COMless
  61. JG short COMgreater
  62. pub CompareMantissas
  63. if fastSP
  64. XOR BH,BL
  65. TEST BH,Single ; Were both args the same length?
  66. JNZ DifferentTypes
  67. TEST BL,Single ; Args same type - Single?
  68. JZ BothDouble
  69. MOV ecx,3 ; Compare 3 bytes of mantissa
  70. DoCompare:
  71. ADD esi,MB7 ; point to most significant byte
  72. ADD edi,MB7
  73. STD
  74. REP CMPS word ptr es:[edi],word ptr ds:[esi]
  75. CLD
  76. else
  77. mov ecx,4 ; compare 4 words of mantissa
  78. ADD esi,MB6 ; point to most significant word
  79. ADD edi,MB6
  80. STD
  81. REP CMPS word ptr [edi],word ptr [esi]
  82. CLD
  83. endif
  84. JB short COMless
  85. JA short COMgreater
  86. pub COMequal
  87. MOV [SWcc],CCequal
  88. JMP short COMexit
  89. if fastSP
  90. DifferentTypes:
  91. TEST BL,Single
  92. JNZ CoerceSI
  93. MOV word ptr MB0[edi],0
  94. MOV word ptr MB2[edi],0
  95. MOV byte ptr MB4[edi],0
  96. MOV ecx,8 ; Compare 8 bytes of mantissa
  97. JMP DoCompare
  98. CoerceSI:
  99. MOV word ptr MB0[esi],0
  100. MOV word ptr MB2[esi],0
  101. MOV byte ptr MB4[esi],0
  102. BothDouble:
  103. MOV ecx,8 ; Compare 8 bytes of mantissa
  104. JMP DoCompare
  105. endif
  106. pub COMless
  107. MOV [SWcc],CCless
  108. JMP short COMexit
  109. pub COMgreater
  110. MOV [SWcc],CCgreater
  111. JMP short COMexit
  112. pub COMincomprable
  113. OR [CURerr],Invalid
  114. pub COMincompr0
  115. MOV [SWcc],CCincomprable
  116. JMP short COMexit
  117. pub COMsignSIinf ; if projective inf numbers are incomprable
  118. TEST [CWcntl],InfinityControl
  119. JZ COMincompr0
  120. pub COMsignSI ; sign of SI tells all (DI = 0)
  121. AND AL,Sign
  122. JS COMless
  123. JMP COMgreater
  124. pub COMsignDIinf ; if projective inf numbers are incomprable
  125. TEST [CWcntl],InfinityControl
  126. JZ COMincompr0
  127. pub COMsignDI ; sign of DI tells all (SI = 0)
  128. AND AH,Sign
  129. JS COMgreater
  130. JMP COMless
  131. pub COMinfinf
  132. TEST [CWcntl],InfinityControl
  133. JZ COMincompr0
  134. XOR AH,AL ; Are signs the same?
  135. AND AH,Sign
  136. JZ COMequal ; yes - infinities are equal
  137. JMP COMsignSI ; else SI negative implies it is less
  138. pub COMexit
  139. OR DX,DX ; do we need to pop the stack?
  140. JZ short COMreturn
  141. POPST
  142. pub COMreturn
  143. RET
  144. pub eFXAM
  145. MOV esi,[CURstk]
  146. mov al, 41h ; see if stack was empty
  147. cmp esi,[BASstk]
  148. je RetFXAM
  149. MOV AX,Flag[esi] ; Sign in AH, Tag in AL
  150. XCHG AL,AH
  151. ROL AX,1
  152. AND AL,7 ; Mask to Tag-Sign
  153. MOV ebx,offset XAMTAB
  154. XLAT byte ptr cs:[ebx] ; Convert to condition code
  155. pub RetFXAM
  156. MOV [SWcc],AL ; Stuff into hi-byte of status word
  157. RET
  158. pub eFTST
  159. MOV esi,[CURstk]
  160. MOV AL,Flag[esi]
  161. AND AL,Sign ; Mask to sign only
  162. XOR ebx,ebx
  163. MOV edx,ebx ; DX 0 to indicate no POP in COMP
  164. MOV BL,Tag[esi]
  165. ifdef i386
  166. jmp TSTtab[4*ebx]
  167. else
  168. SHL ebx,1
  169. JMP TSTtab[ebx]
  170. endif
  171. ProfEnd FCOM
  172.