汇编高手进来(求数组中最小的偶数)

来源:百度知道 编辑:UC知道 时间:2024/07/04 06:12:25
include Allyssa32.inc
.data
array dword 10h,12h,15h,2h,56h,11h,12h
.code
main proc
mov ecx,7
mov ebx,0
lea esi, array
L1:
mov eax,[esi]
cdq
mov edi ,2
idiv edi
cmp edx,0
jne L2
cmp ebx,0
jne L3
mov ebx,[esi]
jmp L2
L3:cmp ebx,[esi]
jl L2
mov ebx,[esi]
L2:add esi,4
loop L1
mov eax,ebx
call writeint
main endp
end main

上面程序执行时,会跳出出错的对话框

include Allyssa32.inc
.data
array dword 10h,12h,15h,2h,56h,11h,12h
.code
main proc
mov ecx,7
mov ebx,0
lea esi, array
L1:
mov eax,[esi]
cdq
mov edi ,2
idiv edi
cmp edx,0
jne L2
cmp ebx,0
jne L3
mov ebx,[esi]
jmp L2
L3:cmp ebx,[esi]
jl L2
mov ebx,[esi]
L2:add esi,4
loop L1
mov eax,ebx
call writeint
main endp
end main