Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; #########################################################################
- ;
- ; FPU Determinants
- ;
- ;##########################################################################
- ;
- ; Procedure to evaluate a NxN determinant
- ;
- ; lpSrc = pointer to array of the determinant's data
- ; uSize = size N of the determinant (N is the rows/columns number)
- ; uType = type of the data
- ; 0 = DWORD
- ; 1 = QWORD
- ; 2 = REAL4
- ; 3 = REAL8
- ; 4 = REAL10
- ;
- ; The result is returned in ST(0) on the FPU.
- ;
- ; The original determinant's data is not modified.
- ;
- ; -----------------------------------------------------------------------
- .386
- .model flat, stdcall ; 32 bit memory model
- option casemap :none ; case sensitive
- include E:\masm32\include\windows.inc
- include E:\masm32\include\kernel32.inc
- includelib E:\masm32\lib\kernel32.lib
- ; The above is simply to indicate the minimum requirements.
- ; Do not repeat if you paste the proc in your app.
- ; #########################################################################
- .data
- M REAL4 2.0
- REAL4 2.0
- REAL4 3.0
- REAL4 4.0
- REAL4 5.0
- REAL4 6.0
- REAL4 7.0
- REAL4 8.0
- REAL4 9.0
- V REAL4 1.0
- REAL4 2.0
- REAL4 3.0
- .code
- FpuDet PROTO STDCALL, lpSrc:DWORD, uSize:DWORD, uType:DWORD
- main proc
- invoke FpuDet, addr M, 3, 2
- db 0CCh ; rF
- ret
- main endp
- FpuDet proc public uses ebx esi edi lpSrc:DWORD, uSize:DWORD, uType:DWORD
- LOCAL hMem :DWORD
- mov eax,uSize
- mul eax
- push eax
- imul eax,10
- invoke LocalAlloc,LPTR,eax
- mov hMem,eax
- mov edi,eax
- mov esi,lpSrc
- pop ecx
- .if uType == 0
- @@:
- fild dword ptr[esi]
- fstp tbyte ptr[edi]
- add esi,4
- add edi,10
- dec ecx
- jnz @B
- .elseif uType == 1
- @@:
- fild qword ptr[esi]
- fstp tbyte ptr[edi]
- add esi,8
- add edi,10
- dec ecx
- jnz @B
- .elseif uType == 2
- @@:
- fld dword ptr[esi]
- fstp tbyte ptr[edi]
- add esi,4
- add edi,10
- dec ecx
- jnz @B
- .elseif uType == 3
- @@:
- fld qword ptr[esi]
- fstp tbyte ptr[edi]
- add esi,8
- add edi,10
- dec ecx
- jnz @B
- .elseif uType == 4
- imul ecx,5
- rep movsw
- .endif
- fld1
- mov ebx,uSize
- det0:
- mov eax,uSize
- sub eax,ebx
- mul uSize
- imul eax,10
- mov edx,uSize
- sub edx,ebx
- imul edx,10
- add eax,edx
- mov esi,hMem
- add esi,eax
- mov edi,uSize
- imul edi,10
- add edi,esi
- fld tbyte ptr[esi]
- fmul st(1),st
- mov ecx,ebx
- dec ecx
- jnz @F
- fstp st
- invoke LocalFree,hMem
- ret
- @@:
- mov edx,ecx
- det1:
- fld tbyte ptr[edi]
- fdiv st,st(1)
- push edi
- push esi
- push edx
- det2:
- add esi,10
- add edi,10
- fld tbyte ptr[esi]
- fmul st,st(1)
- fld tbyte ptr[edi]
- fsubr
- fstp tbyte ptr[edi]
- dec edx
- jnz det2
- pop edx
- pop esi
- pop edi
- mov eax,uSize
- imul eax,10
- add edi,eax
- fstp st
- dec ecx
- jnz det1
- fstp st
- dec ebx
- jmp det0
- FpuDet endp
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement