Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. ; #########################################################################
  2. ;
  3. ; FPU Determinants
  4. ;
  5. ;##########################################################################
  6. ;
  7. ; Procedure to evaluate a NxN determinant
  8. ;
  9. ; lpSrc = pointer to array of the determinant's data
  10. ; uSize = size N of the determinant (N is the rows/columns number)
  11. ; uType = type of the data
  12. ; 0 = DWORD
  13. ; 1 = QWORD
  14. ; 2 = REAL4
  15. ; 3 = REAL8
  16. ; 4 = REAL10
  17. ;
  18. ; The result is returned in ST(0) on the FPU.
  19. ;
  20. ; The original determinant's data is not modified.
  21. ;
  22. ; -----------------------------------------------------------------------
  23.  
  24. .386
  25. .model flat, stdcall ; 32 bit memory model
  26. option casemap :none ; case sensitive
  27.  
  28. include E:\masm32\include\windows.inc
  29.  
  30. include E:\masm32\include\kernel32.inc
  31. includelib E:\masm32\lib\kernel32.lib
  32.  
  33. ; The above is simply to indicate the minimum requirements.
  34. ; Do not repeat if you paste the proc in your app.
  35.  
  36. ; #########################################################################
  37. .data
  38. M REAL4 2.0
  39. REAL4 2.0
  40. REAL4 3.0
  41. REAL4 4.0
  42. REAL4 5.0
  43. REAL4 6.0
  44. REAL4 7.0
  45. REAL4 8.0
  46. REAL4 9.0
  47.  
  48. V REAL4 1.0
  49. REAL4 2.0
  50. REAL4 3.0
  51. .code
  52. FpuDet PROTO STDCALL, lpSrc:DWORD, uSize:DWORD, uType:DWORD
  53.  
  54. main proc
  55. invoke FpuDet, addr M, 3, 2
  56. db 0CCh ; rF
  57. ret
  58. main endp
  59.  
  60. FpuDet proc public uses ebx esi edi lpSrc:DWORD, uSize:DWORD, uType:DWORD
  61.  
  62. LOCAL hMem :DWORD
  63.  
  64. mov eax,uSize
  65. mul eax
  66. push eax
  67. imul eax,10
  68. invoke LocalAlloc,LPTR,eax
  69. mov hMem,eax
  70. mov edi,eax
  71. mov esi,lpSrc
  72. pop ecx
  73. .if uType == 0
  74. @@:
  75. fild dword ptr[esi]
  76. fstp tbyte ptr[edi]
  77. add esi,4
  78. add edi,10
  79. dec ecx
  80. jnz @B
  81. .elseif uType == 1
  82. @@:
  83. fild qword ptr[esi]
  84. fstp tbyte ptr[edi]
  85. add esi,8
  86. add edi,10
  87. dec ecx
  88. jnz @B
  89. .elseif uType == 2
  90. @@:
  91. fld dword ptr[esi]
  92. fstp tbyte ptr[edi]
  93. add esi,4
  94. add edi,10
  95. dec ecx
  96. jnz @B
  97. .elseif uType == 3
  98. @@:
  99. fld qword ptr[esi]
  100. fstp tbyte ptr[edi]
  101. add esi,8
  102. add edi,10
  103. dec ecx
  104. jnz @B
  105. .elseif uType == 4
  106. imul ecx,5
  107. rep movsw
  108. .endif
  109.  
  110. fld1
  111. mov ebx,uSize
  112. det0:
  113. mov eax,uSize
  114. sub eax,ebx
  115. mul uSize
  116. imul eax,10
  117. mov edx,uSize
  118. sub edx,ebx
  119. imul edx,10
  120. add eax,edx
  121. mov esi,hMem
  122. add esi,eax
  123. mov edi,uSize
  124. imul edi,10
  125. add edi,esi
  126.  
  127. fld tbyte ptr[esi]
  128. fmul st(1),st
  129. mov ecx,ebx
  130. dec ecx
  131. jnz @F
  132. fstp st
  133. invoke LocalFree,hMem
  134. ret
  135.  
  136. @@:
  137. mov edx,ecx
  138. det1:
  139. fld tbyte ptr[edi]
  140. fdiv st,st(1)
  141. push edi
  142. push esi
  143. push edx
  144. det2:
  145. add esi,10
  146. add edi,10
  147. fld tbyte ptr[esi]
  148. fmul st,st(1)
  149. fld tbyte ptr[edi]
  150. fsubr
  151. fstp tbyte ptr[edi]
  152. dec edx
  153. jnz det2
  154. pop edx
  155. pop esi
  156. pop edi
  157. mov eax,uSize
  158. imul eax,10
  159. add edi,eax
  160. fstp st
  161. dec ecx
  162. jnz det1
  163. fstp st
  164. dec ebx
  165. jmp det0
  166.  
  167. FpuDet endp
  168. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement