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.

101 lines
2.2 KiB

  1. page ,132
  2. subttl emfmisc.asm - Miscellaneous Operations
  3. ;***
  4. ;emfmisc.asm - Miscellaneous Operations
  5. ;
  6. ; Copyright (c) 1987-89, Microsoft Corporation
  7. ;
  8. ;Purpose:
  9. ; Miscellaneous Operations: FABS, FCHS, DupTOS, FSCALE, FXCHG
  10. ;
  11. ;
  12. ; This Module contains Proprietary Information of Microsoft
  13. ; Corporation and should be treated as Confidential.
  14. ;
  15. ;Revision History:
  16. ; See emulator.hst
  17. ;
  18. ;*******************************************************************************
  19. ProfBegin FMISC
  20. pub eFABS
  21. MOV esi,[CURstk] ; point to TOS
  22. AND byte ptr Flag[esi],0FFH - Sign ; mask off sign
  23. RET
  24. pub eFCHS
  25. MOV esi,[CURstk] ; point to TOS
  26. XOR byte ptr Flag[esi],Sign ; toggle the sign
  27. RET
  28. ; FLDCW and FSTCW should only be used in a nested fashion
  29. ; and should never change the denormal and invalid masks (in real 8087)
  30. ;
  31. ; FSTCW old
  32. ; FLDCW new ; new and old have same denormal/invalid masks
  33. ; ...
  34. ; FLDCW old
  35. pub eFLDCW
  36. LDUS2AX ; Fetch control word from user memory
  37. MOV [ControlWord],AX ; Store in the emulated control word
  38. MOV [UserControlWord],AX ; Store in the user control word
  39. RET
  40. pub eFSTCW
  41. MOV AX,[UserControlWord] ; Fetch user control word
  42. MOV edi,esi
  43. STAX2US ; Store into user memory
  44. RET
  45. pub eFSTSW
  46. MOV AX,[StatusWord] ; Fetch emulated Status word
  47. MOV edi,esi
  48. STAX2US ; Store into user memory
  49. RET
  50. pub eFSCALE ; NOS is treated as short integer and TOS gets
  51. MOV esi,[CURstk] ; its exponent bumped by that amount
  52. MOV edi,esi
  53. ChangeDIfromTOStoNOS
  54. MOV CL,15
  55. MOV AL,Expon[edi] ; Assume word integer
  56. AND AL,0FH ; Assume exp is positive and in range
  57. SUB CL,AL ; Generate shift count for mantissa
  58. MOV AX,MB6[edi] ; MSW will contain the whole integer
  59. SHR AX,CL ; AX is now the integer
  60. MOV CL,Flag[edi] ; Get the sign for the integer
  61. OR CL,CL
  62. JNS short GotExponInc
  63. NEG AX
  64. pub GotExponInc
  65. ADD AX,Expon[esi]
  66. JO short ExpOverflowed
  67. CMP AX,IexpMax - IexpBias
  68. JGE short ScaledToInfinity
  69. CMP AX,IexpMin - IexpBias
  70. JLE short ScaledToZero
  71. pub ScaleReturn
  72. MOV Expon[esi],AX
  73. RET
  74. pub ExpOverflowed
  75. JNS short ScaledToZero
  76. pub ScaledToInfinity
  77. MOV AX,IexpMax - IexpBias
  78. MOV byte ptr Tag[esi],Special + ZROorINF
  79. JMP short ScaleReturn
  80. pub ScaledToZero
  81. MOV AX,IexpMin - IexpBias
  82. MOV byte ptr Tag[esi],ZROorINF
  83. JMP short ScaleReturn
  84. ProfEnd FMISC