2011-12-15 2 views
-3
.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

코드와 실제 문제에 대한 설명 좋을 텐데 ... – Matteo

+0

* 적어도 * 당신이 –

답변

2

나쁜 :

ReleaseArray MACRO ELem 
REPT ELem 
pop edi 
ENDM 
ENDM 

좋은 :

ReleaseArray MACRO ELem 
REPT ELem 
pop edi 
ReleaseArray ENDM   ; or just ENDM 
+0

을 사용하고있는 어셈블러 지정하십시오 오류 메시지만으로 오버플로 스택에 게시하고 게시물을 컴파일하거나 어셈블 할 때마다 스크립트를 작성한 다음 작동 할 때까지 모든 대답을 시도해야합니다. 그래도 오류를 찾는 훌륭한 직장 :) –

+0

나는 질문을 한 사람이 아니기 때문에 나는 할 수 없다. –