.686
.MODEL flat, stdcall
.STACK
INCLUDE Irvine32.inc
ReleaseArray MACRO ELem
REPT ELem
pop edi
ENDM
ENDM
det MACRO Dim
Local Start ,skip , L1,L2,Els ,Elm
;recives array in stack
;recives,dh num elements,dl dimisien
;produce det in eax
mov edx ,Dim ;Elm = Dim*Dim
shl edx,1
mov Elm ,edx
push ebp
mov ebp,esp
Start: cmp Dim,1
jne els
mov eax,[ebp+4]
ret 4
els:
movzx ecx,Dim
xor esi,esi
xor eax,eax
L1: inc esi
push ecx
push esi
push eax
; push array
mov edi,dim
mov ecx , Elm-dim
L2: mov eax,dim
div edi
cmp esi , edx
Je skip
push [ebp+edi*4]
skip: inc edi
Loop L2
;=========
det Dim-1
imul [ebp+esi*4]
test esi,1
jne next
imul -1
next:
pop ebx
add eax,ebx
pop esi
pop ecx
loop L1
pop ebp
ReleaseArray Elm
ret
det ENDM
.DATA
Array dword 2500 dup(?)
String1 byte "Enter Dimension of matrix : " ,0
String2 byte "The Ditermenant of the matrix : " ,0
.CODE
main PROC
lea edx,String1
call writestring
call readint
mov ebx,eax
mul ebx
mov ecx,eax
xor edi,edi
Read: call Readint
push eax
mov Array[edi*4],eax
inc edi
loop Read
det ebx
push eax
mov cl,dl
xor edi,edi
column:
push ecx
mov cl,dl
Row:
mov eax,Array[edi*4]
call writeInt
inc edi
mov al,09h
call writechar
loop Row
call crlf
pop ecx
loop column
lea edx,String2
call writestring
pop eax
call writeint
call crlf
call waitmsg
exit
main ENDP
end main
答案 0 :(得分:2)
坏:
ReleaseArray MACRO ELem
REPT ELem
pop edi
ENDM
ENDM
好:
ReleaseArray MACRO ELem
REPT ELem
pop edi
ReleaseArray ENDM ; or just ENDM