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.

256 lines
4.7 KiB

  1. page ,132
  2. subttl emdecode.asm - Instruction decoding
  3. ;***
  4. ;emdecode.asm - Instruction decoding
  5. ;
  6. ; Copyright (c) 1987-89, Microsoft Corporation
  7. ;
  8. ;Purpose:
  9. ; Instruction decoding.
  10. ; Further decoding of instructions done here.
  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 DECODE
  20. even
  21. pub eFLDsdri
  22. MOV BX,CX ; Dispatch on MF
  23. AND ebx,6H
  24. ifdef i386
  25. JMP FLDsdriTab[2*ebx]
  26. else
  27. JMP FLDsdriTab[ebx]
  28. endif
  29. pub eFSTsdri
  30. MOV BX,CX ; Dispatch on MF
  31. AND ebx,6H
  32. ifdef i386
  33. JMP FSTsdriTab[2*ebx]
  34. else
  35. JMP FSTsdriTab[ebx]
  36. endif
  37. even
  38. pub eFSTPsdri
  39. mov bx, cx ; Dispatch on MF
  40. and ebx, 6h
  41. ifdef i386
  42. call FSTsdriTab[2*ebx]
  43. else
  44. call FSTsdriTab[ebx]
  45. endif
  46. mov esi, [CURstk]
  47. cmp esi, [BASstk] ; Do we have an empty stack?
  48. jbe short FSTPSTUnder ; Yes, Underflow.
  49. FSTPSTOk:
  50. sub esi, Reg87Len ; decrement SI to previous register
  51. mov [CURstk], esi ; set current top of stack
  52. ret
  53. FSTPSTUnder:
  54. call UnderStk ; stack underflow error
  55. jmp FSTPSTOk
  56. pub eFLDtempORcw
  57. MOV BX,CX ; Dispatch on MF
  58. AND ebx,6H
  59. ifdef i386
  60. JMP FLDtempORcwTab[2*ebx]
  61. else
  62. JMP FLDtempORcwTab[ebx]
  63. endif
  64. pub eFSTtempORcw
  65. MOV BX,CX ; Dispatch on MF
  66. AND ebx,6H
  67. ifdef i386
  68. JMP FSTtempORcwTab[2*ebx]
  69. else
  70. JMP FSTtempORcwTab[ebx]
  71. endif
  72. pub eFLDregOrFFREE ; We only emulate FLD ST (Duplicate TOS)
  73. ;CX = |Op|r/m|MOD|esc|MF|Arith|
  74. test cx,06h ; test MF. MF=01 is FFREE, MF=00 is FLD ST(i)
  75. jnz short jmpeFFREE ; go emulate FFREE
  76. jmp eFLDreg ; emulate FLD ST(i)
  77. jmpeFFREE:
  78. jmp eFFREE ; emulate FFREE ST(i)
  79. pub eMISCELANEOUS ; We only emulate FCHS, FABS, FTST, & FXAM
  80. ; FCLEX is emulated in non-IBM version
  81. TEST CX,0806H ; We already have match on Op,MOD,&Arith
  82. jz short MFzero ; MF = 0, must be FCHS, FABS, FTST or FXAM
  83. ; check for FCLEX (cx = 8B03)
  84. xor cx,00203h ; toggle low bit of MF and middle bit of r/m
  85. test cx,00603h ; test for zero in MF and r/m fields
  86. jnz short jnzUNUSED ; MF <> 01 and/or r/m <> 010 => unemulated
  87. cmp cx,8104h ; check for FSTSW AX
  88. je short eFSTSWAX ; yes
  89. mov [StatusWord],0 ; FCLEX: clear status word
  90. ret
  91. pub eFSTSWAX
  92. ifdef XENIX
  93. xor eax,eax ; UNDONE - set to non-zero - cleanup code
  94. else
  95. push sp ; test for 286 !!!
  96. pop ax
  97. cmp ax,sp
  98. endif
  99. pub jnzUNUSED
  100. jnz UNUSED ; UNUSED if not 286
  101. mov ax,[StatusWord] ; FSTSW AX: save status word in AX
  102. mov [ebp].regAX,ax ; overwrite AX stack entry
  103. ret
  104. MFzero:
  105. TEST CX,1000H
  106. JZ short FABSorFCHS
  107. TEST CX,0400H ; r/m = 101 for FXAM
  108. JNZ short JMPeFXAM ; r/m = 100 for FTST
  109. JMP eFTST
  110. pub JMPeFXAM
  111. JMP eFXAM
  112. pub FABSorFCHS
  113. TEST CX,0400H ; r/m = 001 for FABS
  114. JNZ short JMPeFABS ; r/m = 000 for FCHS
  115. JMP eFCHS
  116. pub JMPeFABS
  117. JMP eFABS
  118. pub eFLDconstants
  119. MOV BL,CH ; Mov r/m field to BX for jump
  120. SHR BL,1
  121. AND ebx,0EH
  122. ifdef i386
  123. JMP FLDconstantsTab[2*ebx]
  124. else
  125. JMP FLDconstantsTab[ebx]
  126. endif
  127. pub eTranscendental
  128. MOV BL,CH ; Mov r/m field to BX for jump
  129. SHR BL,1
  130. AND ebx,0EH
  131. ifdef i386
  132. JMP TranscendentalTab[2*ebx]
  133. else
  134. JMP TranscendentalTab[ebx]
  135. endif
  136. pub eVARIOUS
  137. MOV BL,CH ; Mov r/m field to BX for jump
  138. SHR BL,1
  139. AND ebx,0EH
  140. ifdef i386
  141. JMP VariousTab[2*ebx]
  142. else
  143. JMP VariousTab[ebx]
  144. endif
  145. pub eFXCHGreg ; only valid FXCHG is with r/m = 001, MF = 00
  146. TEST CX,06h ; only valid FXCHG is with MF = 0
  147. JNZ short UNUSED ; unemulated
  148. JMP eFXCHG ; emulate FXCH ST(i)
  149. pub eFSTPreg
  150. xor cl,04h ; test for MF = 10, valid encoding of FSTP ST(x)
  151. test cx,06h
  152. jne short UNUSED ; MF <> 10, no such instruction
  153. mov ax,1 ; indicate stack should be popped after xfer
  154. jmp eFST_Preg ; emulate FSTP ST(x)
  155. ;*** eFSTreg - decode FST ST(i),FNOP
  156. ;
  157. ; ARGUMENTS
  158. ; CX = |Op|r/m|MOD|esc|MF|Arith|
  159. ;
  160. ; DESCRIPTION
  161. ; All parts of the instruction except MF and r/m have already
  162. ; been decoded. If MF=0, the instruction is FNOP, which is
  163. ; unemulated. Otherwise, clear AX to indicate FST ST(i), then
  164. ; jump to eFST_Preg, the common emulator routine for
  165. ; FST ST(i) and FSTP ST(i).
  166. ;
  167. eFSTreg:
  168. test cl,06h ;test for MF = 0
  169. jz short UNUSED ;MF=0 ==> FNOP, which is unemulated
  170. ;otherwise this is FST ST(i)
  171. xor ax,ax ;clear ax to indicate FST ST(i), not FSTP ST(i)
  172. jmp eFST_Preg ; emulate FSTP ST(x)
  173. ; This sets the error flag indicating Unemulated functions
  174. eFXTRACT:
  175. eFDECSTP:
  176. eFINCSTP:
  177. ifdef frontend ; unused instructions for frontend version
  178. eFLDL2T:
  179. eFLDL2E:
  180. eFLDPI:
  181. eFLDLG2:
  182. eFLDLN2:
  183. eFPREM:
  184. eF2XM1:
  185. eFYL2X:
  186. eFPTAN:
  187. eFPATAN:
  188. eFYL2XP1:
  189. eFSQRT:
  190. endif ;frontend
  191. ifdef SMALL_EMULATOR
  192. eFLDL2T:
  193. eFLDL2E:
  194. eFLDPI:
  195. eFLDLG2:
  196. eFLDLN2:
  197. eFPREM:
  198. eF2XM1:
  199. eFYL2X:
  200. eFPTAN:
  201. eFPATAN:
  202. eFYL2XP1:
  203. eFSQRT:
  204. endif ;SMALL_EMULATOR
  205. pub UNUSED
  206. OR [CURerr],Unemulated
  207. RET
  208. ProfEnd DECODE