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.

275 lines
5.4 KiB

  1. ;
  2. ;
  3. ; Copyright (C) Microsoft Corporation, 1986
  4. ;
  5. ; This Module contains Proprietary Information of Microsoft
  6. ; Corporation and should be treated as Confidential.
  7. ;
  8. subttl emintern.asm - Emulator Internal Format and Macros
  9. page
  10. ;---------------------------------------------------------------------------
  11. ;
  12. ; Emulator Internal Format:
  13. ;
  14. ; +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11
  15. ; .___.___.___.___.___.___.___.___.___.___.___.___.
  16. ; ptr --> |___|___|___|___|___|___|___|___|___|___|___|___|
  17. ; lsb msb exl exh flg tag
  18. ; |<--- mantissa --->|exponent
  19. ;
  20. ; The mantissa contains the leading 1 before the decimal point in the hi
  21. ; bit of the msb. The exponent is not biased i.e. it is a signed integer.
  22. ; The flag and tag bytes are as below.
  23. ;
  24. ; bit: 7 6 5 4 3 2 1 0
  25. ; .___.___.___.___.___.___.___.___.
  26. ; Flag: |___|_X_|_X_|_X_|_X_|_X_|_X_|___| X = unused
  27. ; ^ ^
  28. ; SIGN SINGLE (=1 if single precision)
  29. ;
  30. ;
  31. ; bit: 7 6 5 4 3 2 1 0
  32. ; .___.___.___.___.___.___.___.___.
  33. ; Tag: |_X_|_X_|_X_|_X_|_X_|_X_|___|___| X = unused
  34. ; ^ ^
  35. ; | |
  36. ; Special (Set for NAN or Inf) ---+ |
  37. ; ZROorINF (Set for 0 or Inf) -------+
  38. ;
  39. PAGE
  40. ; Data Structure Equates
  41. Lsb equ 0
  42. Msb equ 7
  43. MB0 equ 0
  44. MB1 equ 1
  45. MB2 equ 2
  46. MB3 equ 3
  47. MB4 equ 4
  48. MB5 equ 5
  49. MB6 equ 6
  50. MB7 equ 7
  51. Expon equ 8
  52. Flag equ 10
  53. Sign equ 128
  54. if fastSP
  55. Single equ 1
  56. endif
  57. Tag equ 11
  58. Special equ 2
  59. ZROorINF equ 1
  60. Reg87Len equ 12
  61. MantissaByteCnt equ Msb - Lsb + 1
  62. IexpBias equ 3FFFh ; 16,383
  63. IexpMax equ 7FFFh ; Biased Exponent for Infinity
  64. IexpMin equ 0 ; Biased Exponent for zero
  65. DexpBias equ 3FFh ; 1023
  66. DexpMax equ 7FFh ; Biased Exponent for Infinity
  67. DexpMin equ 0 ; Biased Exponent for zero
  68. SexpBias equ 07Fh ; 127
  69. SexpMax equ 0FFh ; Biased Exponent for Infinity
  70. SexpMin equ 0 ; Biased Exponent for zero
  71. ; Control Word Format CWcntl
  72. InfinityControl equ 10h
  73. ICaffine equ 10h
  74. ICprojective equ 0
  75. RoundControl equ 0Ch
  76. RCchop equ 0Ch
  77. RCup equ 08h
  78. RCdown equ 04h
  79. RCnear equ 0
  80. PrecisionControl equ 03h
  81. PC24 equ 0
  82. PC53 equ 02h
  83. PC64 equ 03h
  84. ; Status Word Format SWcc
  85. C0 equ 01h
  86. C1 equ 02h
  87. C2 equ 04h
  88. C3 equ 40h
  89. ConditionCode equ C0 + C1 + C2+ C3
  90. CCgreater equ 0
  91. CCless EQU C0
  92. CCequal equ C3
  93. CCincomprable equ C3 + C2 + C0
  94. ; Status Flags Format CURerr
  95. Invalid equ 1h ; chip status flags
  96. Denormal equ 2h
  97. ZeroDivide equ 4h
  98. Overflow equ 8h
  99. Underflow equ 10h
  100. Precision equ 20h
  101. Unemulated equ 40h ; soft status flags
  102. SquareRootNeg equ 80h
  103. IntegerOverflow equ 100h
  104. StackOverflow equ 200h
  105. StackUnderflow equ 400h
  106. UStatMask equ 1FFFh ; user status flags
  107. MemoryOperand equ 2000h ; special instruction flags
  108. Reexecuted equ 4000h
  109. ; floating point error signals (also used as DOS return code)
  110. errInvalid equ 81h ; sorted as above
  111. errDenormal equ 82h
  112. errZeroDivide equ 83h
  113. errOverflow equ 84h
  114. errUnderflow equ 85h
  115. errPrecision equ 86h
  116. errUnemulated equ 87h
  117. errSquareRootNeg equ 88h
  118. errIntegerOverflow equ 89h
  119. errStackOverflow equ 8Ah
  120. errStackUnderflow equ 8Bh
  121. subttl emintern.asm - Emulator interrupt frame
  122. page
  123. ; define emulator interrupt frame
  124. ifdef i386
  125. ifdef XENIX
  126. ; 386 frame for XENIX
  127. frame struc ; emulator interrupt frame
  128. regEAX dd ? ; 386 registers
  129. regECX dd ?
  130. regEDX dd ?
  131. regEBX dd ?
  132. regESP dd ?
  133. regEBP dd ?
  134. regESI dd ?
  135. regEDI dd ?
  136. regSegOvr dw ?,? ; segment override for bp relative EAs
  137. regES dw ?,?
  138. regDS dw ?,?
  139. regAX dw ?,? ; original EAX - stuff area for FSTSW AX
  140. regSS dd ? ; need to save ss
  141. regEIP dd ?
  142. regCS dw ?,?
  143. regFlg dd ?
  144. frame ends
  145. else
  146. ; 386 frame
  147. frame struc ; emulator interrupt frame
  148. regEAX dd ? ; 386 registers
  149. regECX dd ?
  150. regEDX dd ?
  151. regEBX dd ?
  152. regESP dd ?
  153. regEBP dd ?
  154. regESI dd ?
  155. regEDI dd ?
  156. regSegOvr dw ?,? ; segment override for bp relative EAs
  157. regES dw ?,?
  158. regDS dw ?,?
  159. regAX dw ?,? ; original EAX - stuff area for FSTSW AX
  160. regEIP dd ?
  161. regCS dw ?,?
  162. regFlg dd ?
  163. frame ends
  164. endif
  165. else
  166. ; 286 frame
  167. frame struc ; emulator interrupt frame
  168. regBP dw ?
  169. regSegOvr dw ? ; segment override for bp relative EAs
  170. regBX dw ?
  171. regCX dw ?
  172. regDX dw ?
  173. regSI dw ?
  174. regDI dw ?
  175. regDS dw ?
  176. regES dw ?
  177. regAX dw ?
  178. regIP dw ?
  179. regCS dw ?
  180. regFlg dw ?
  181. frame ends
  182. endif ;i386
  183. subttl emintern.asm - User Memory Management Macros
  184. page
  185. ;*********************************************************************;
  186. ; ;
  187. ; User Memory Management Macros ;
  188. ; ;
  189. ;*********************************************************************;
  190. ; All user data access uses these five macros.
  191. ; Load user memory word at (DS:)SI to AX register; smash AX only
  192. LDUS2AX MACRO
  193. lods word ptr es:[esi] ; 12 move word from ES:SI to AX
  194. ENDM
  195. ; Store word from AX to user memory at (ES:)DI; smash AX only
  196. STAX2US MACRO
  197. stos word ptr es:[edi] ; 10 move word from AX to ES:DI
  198. ENDM
  199. ; Move user memory word at (DS:)SI to local at (ES:)DI; smash AX only
  200. MVUS2DI MACRO
  201. movs word ptr es:[edi],word ptr ds:[esi] ; 18 move word from DS:SI to ES:DI
  202. ENDM
  203. ; Move local word at (DS:)SI to user memory at (ES:)DI; smash AX only
  204. MVSI2US MACRO
  205. movs word ptr es:[edi],word ptr ds:[esi] ; 18 move word from DS:SI to ES:DI
  206. ENDM
  207. ; Move local word at (CS:)SI to user memory at (ES:)DI; smash AX only
  208. csMVSI2US MACRO
  209. movs word ptr es:[edi],word ptr cs:[esi]
  210. ENDM
  211.