Leaked source code of windows server 2003
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.

284 lines
8.9 KiB

  1. ; Static Name Aliases
  2. ;
  3. TITLE testa.asm
  4. NAME testa
  5. .386p
  6. include callconv.inc
  7. EXTRNP _DivMarker,0
  8. _DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
  9. public _DivOperand, _DivRegPointer, _DivRegScaler, _ExceptEip, _ExceptEsp
  10. _DivOperand dd ?
  11. _DivRegPointer dd ?
  12. _DivRegScaler dd ?
  13. _ExceptEip dd ?
  14. _ExceptEsp dd ?
  15. public _TestTable, _TestTableCenter
  16. _TestTable dd 64 dup (?)
  17. _TestTableCenter dd 64 dup (?)
  18. _DATA ENDS
  19. DivTest macro div,reg,type,labelmod
  20. ; public &div&_&type&_&reg&labelmod - too many labels
  21. &div&_&type&_&reg&labelmod:
  22. endm
  23. endtest macro
  24. call Marker
  25. dd 0CCCCCCCCh ; marker for expcetion
  26. ; handler to find next test
  27. endm
  28. REGDiv macro type, reglist
  29. irp reg,<reglist>
  30. DivTest div, reg, type, _reg
  31. mov eax, 7f7f7f7fh
  32. mov edx, eax
  33. mov reg, type ptr _DivOperand
  34. div reg
  35. endtest
  36. DivTest idiv, reg, type, _reg
  37. mov eax, 7f7f7f7fh
  38. mov edx, eax
  39. mov reg, type ptr _DivOperand
  40. idiv reg
  41. endtest
  42. endm
  43. endm
  44. PTRDiv macro typelist
  45. irp type,<typelist>
  46. DivTest div, reg, type, _ptr
  47. mov edx, _DivOperand
  48. ifidni <type>,<byte>
  49. mov byte ptr _TestTableCenter, dl
  50. else
  51. ifidni <type>,<word>
  52. mov word ptr _TestTableCenter, dx
  53. else
  54. mov dword ptr _TestTableCenter, edx
  55. endif
  56. endif
  57. mov eax, 7f7f7f7fh
  58. mov edx, eax
  59. div type ptr _TestTableCenter
  60. endtest
  61. DivTest idiv, reg, type, _ptr
  62. mov edx, _DivOperand
  63. ifidni <type>,<byte>
  64. mov byte ptr _TestTableCenter, dl
  65. else
  66. ifidni <type>,<word>
  67. mov word ptr _TestTableCenter, dx
  68. else
  69. mov dword ptr _TestTableCenter, edx
  70. endif
  71. endif
  72. mov eax, 7f7f7f7fh
  73. mov edx, eax
  74. idiv type ptr _TestTableCenter
  75. endtest
  76. endm
  77. endm
  78. REGDivP1 macro type, offset, divpointer, labelmod, reglist
  79. irp reg,<reglist>
  80. DivTest div, reg, type, labelmod
  81. mov eax, divpointer
  82. mov edx, _DivOperand
  83. ifidni <type>,<byte>
  84. mov byte ptr [eax + offset], dl
  85. else
  86. ifidni <type>,<word>
  87. mov word ptr [eax + offset], dx
  88. else
  89. mov dword ptr [eax + offset], edx
  90. endif
  91. endif
  92. mov eax, 7f7f7f7fh
  93. mov edx, eax
  94. mov reg, divpointer
  95. div type ptr [reg + offset]
  96. endtest
  97. DivTest idiv, reg, type, labelmod
  98. mov eax, divpointer
  99. mov edx, _DivOperand
  100. ifidni <type>,<byte>
  101. mov byte ptr [eax + offset], dl
  102. else
  103. ifidni <type>,<word>
  104. mov word ptr [eax + offset], dx
  105. else
  106. mov dword ptr [eax + offset], edx
  107. endif
  108. endif
  109. mov eax, 7f7f7f7fh
  110. mov edx, eax
  111. mov reg, divpointer
  112. idiv type ptr [reg + offset]
  113. endtest
  114. endm
  115. endm
  116. REGDivSIB1 macro type, offset, divpointer, labelmod, toscale, scaler, reglist
  117. irp reg,<reglist>
  118. DivTest div, reg, type, labelmod
  119. push ebx
  120. mov eax, divpointer
  121. mov edx, _DivOperand
  122. mov ebx, _DivRegScaler
  123. ifidni <type>,<byte>
  124. mov byte ptr [ebx * toscale + eax + offset], dl
  125. else
  126. ifidni <type>,<word>
  127. mov word ptr [ebx * toscale + eax + offset], dx
  128. else
  129. mov dword ptr [ebx * toscale + eax + offset], edx
  130. endif
  131. endif
  132. pop ebx
  133. mov eax, 7f7f7f7fh
  134. mov edx, eax
  135. mov reg, divpointer
  136. mov scaler, _DivRegScaler
  137. div type ptr [scaler * toscale + reg + offset]
  138. endtest
  139. DivTest idiv, reg, type, labelmod
  140. push ebx
  141. mov eax, divpointer
  142. mov edx, _DivOperand
  143. mov ebx, _DivRegScaler
  144. ifidni <type>,<byte>
  145. mov byte ptr [ebx * toscale + eax + offset], dl
  146. else
  147. ifidni <type>,<word>
  148. mov word ptr [ebx * toscale + eax + offset], dx
  149. else
  150. mov dword ptr [ebx * toscale + eax + offset], edx
  151. endif
  152. endif
  153. pop ebx
  154. mov eax, 7f7f7f7fh
  155. mov edx, eax
  156. mov reg, divpointer
  157. mov scaler, _DivRegScaler
  158. idiv type ptr [scaler * toscale + reg + offset]
  159. endtest
  160. endm
  161. endm
  162. REGDivP macro typelist, reglist
  163. irp type, <typelist>
  164. REGDivP1 type, 0, _DivRegPointer, _d, <reglist>
  165. REGDivP1 type, 1, _DivRegPointer, _p, <reglist>
  166. REGDivP1 type, -1, _DivRegPointer, _m, <reglist>
  167. REGDivP1 type, _TestTableCenter, 0, _rd, <reglist>
  168. REGDivP1 type, _TestTableCenter, 1, _rp, <reglist>
  169. REGDivP1 type, _TestTableCenter, -1, _rm, <reglist>
  170. endm
  171. endm
  172. REGDivSIB macro typelist, scaler, reglist
  173. irp type, <typelist>
  174. REGDivSIB1 type, 0, _DivRegPointer, _&scaler&_d, 1, scaler, <reglist>
  175. REGDivSIB1 type, 1, _DivRegPointer, _&scaler&_p, 1, scaler, <reglist>
  176. REGDivSIB1 type, -1, _DivRegPointer, _&scaler&_m, 1, scaler, <reglist>
  177. REGDivSIB1 type, _TestTableCenter, 0, _&scaler&_rd, 1, scaler, <reglist>
  178. REGDivSIB1 type, _TestTableCenter, 1, _&scaler&_rp, 1, scaler, <reglist>
  179. REGDivSIB1 type, _TestTableCenter, -1, _&scaler&_rm, 1, scaler, <reglist>
  180. ;---
  181. REGDivSIB1 type, 0, _DivRegPointer, _&scaler&_d2, 2, scaler, <reglist>
  182. REGDivSIB1 type, 1, _DivRegPointer, _&scaler&_p2, 2, scaler, <reglist>
  183. REGDivSIB1 type, -1, _DivRegPointer, _&scaler&_m2, 2, scaler, <reglist>
  184. REGDivSIB1 type, _TestTableCenter, 0, _&scaler&_r2d, 2, scaler, <reglist>
  185. REGDivSIB1 type, _TestTableCenter, 1, _&scaler&_r2p, 2, scaler, <reglist>
  186. REGDivSIB1 type, _TestTableCenter, -1, _&scaler&_r2m, 2, scaler, <reglist>
  187. ;---
  188. REGDivSIB1 type, 0, _DivRegPointer, _&scaler&_d4, 4, scaler, <reglist>
  189. REGDivSIB1 type, 1, _DivRegPointer, _&scaler&_p4, 4, scaler, <reglist>
  190. REGDivSIB1 type, -1, _DivRegPointer, _&scaler&_m4, 4, scaler, <reglist>
  191. REGDivSIB1 type, _TestTableCenter, 0, _&scaler&_r4d, 4, scaler, <reglist>
  192. REGDivSIB1 type, _TestTableCenter, 1, _&scaler&_r4p, 4, scaler, <reglist>
  193. REGDivSIB1 type, _TestTableCenter, -1, _&scaler&_r4m, 4, scaler, <reglist>
  194. ;---
  195. REGDivSIB1 type, 0, _DivRegPointer, _&scaler&_d8, 8, scaler, <reglist>
  196. REGDivSIB1 type, 1, _DivRegPointer, _&scaler&_p8, 8, scaler, <reglist>
  197. REGDivSIB1 type, -1, _DivRegPointer, _&scaler&_m8, 8, scaler, <reglist>
  198. REGDivSIB1 type, _TestTableCenter, 0, _&scaler&_r8d, 8, scaler, <reglist>
  199. REGDivSIB1 type, _TestTableCenter, 1, _&scaler&_r8p, 8, scaler, <reglist>
  200. REGDivSIB1 type, _TestTableCenter, -1, _&scaler&_r8m, 8, scaler, <reglist>
  201. endm
  202. endm
  203. _TEXT SEGMENT DWORD PUBLIC USE32 'CODE' ; Start 32 bit code
  204. ASSUME CS:FLAT, DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  205. cPublicProc _TestDiv
  206. ; save c runtime registers
  207. push ebp
  208. push ebx
  209. push esi
  210. push edi
  211. ; prime outer loop with initial exception
  212. endtest
  213. ; start of div test
  214. PTRDiv <byte, word, dword>
  215. REGDiv <byte>, <bl,bh,cl,ch,dl,dh>
  216. REGDiv <word>, <ax,bx,cx,si,di,bp>
  217. REGDiv <dword>, <ebx,ecx,edx,esi,edi,ebp>
  218. REGDivP <byte>, <ebx,ecx,edx,esi,edi,ebp>
  219. REGDivP <word, dword>, <eax,ebx,ecx,esi,edi,ebp>
  220. REGDivSIB <byte>, <ebx>, <ecx,edx,esi,edi,ebp>
  221. REGDivSIB <byte>, <ecx>, <ebx,edx,esi,edi,ebp>
  222. REGDivSIB <byte>, <edx>, <ebx,ecx,esi,edi,ebp>
  223. REGDivSIB <byte>, <esi>, <ebx,ecx,edx,edi,ebp>
  224. REGDivSIB <byte>, <edi>, <ebx,ecx,edx,esi,ebp>
  225. REGDivSIB <byte>, <ebp>, <ebx,ecx,edx,edi,esi>
  226. REGDivSIB <word, dword>, <eax>, <ebx,ecx,esi,edi,ebp>
  227. REGDivSIB <word, dword>, <ebx>, <eax,ecx,esi,edi,ebp>
  228. REGDivSIB <word, dword>, <ecx>, <eax,ebx,esi,edi,ebp>
  229. REGDivSIB <word, dword>, <esi>, <eax,ebx,ecx,edi,ebp>
  230. REGDivSIB <word, dword>, <edi>, <eax,ebx,ecx,esi,ebp>
  231. REGDivSIB <word, dword>, <ebp>, <eax,ebx,ecx,edi,esi>
  232. ; end of test
  233. pop edi
  234. pop esi
  235. pop ebx
  236. pop ebp
  237. stdRET _TestDiv
  238. stdENDP _TestDiv
  239. cPublicProc Marker
  240. pop eax
  241. mov _ExceptEip, eax
  242. mov _ExceptEsp, esp
  243. stdCall _DivMarker
  244. int 3
  245. stdENDP Marker
  246. _TEXT ENDS
  247. END