【发布时间】:2015-07-28 17:18:39
【问题描述】:
我修复了错误,但现在有人可以建议一种方法让CountNearMatches 计算两个数组中有多少近匹配项。我使用 diff 变量作为最大允许差异。
这是我目前所拥有的:
INCLUDE Irvine32.inc
CountNearMatches PROTO, ; procedure prototype
arr1:PTR SDWORD,
arr2:PTR SDWORD,
diff3:DWORD
.data
arraySyze DWORD 6
diff DWORD 3
index DWORD 0 ;var to use as the first index
Array1 SDWORD 15, 9, 11, 13, 19, 6
Array2 SDWORD 14, 5, 3, 12, 1, 4
text1 BYTE "************* ASM *****************", 0
text2 BYTE "*** Counting Nearly Matching Elements ***", 0
text3 BYTE "the arrays are:...", 0
text4 BYTE "Nearly Mathces were: ",0
.code
main PROC
mov edx, offset text1 ;hands the address of the firs char of text1
call WriteString ;prints out text1
call Crlf
call Crlf
mov edx, offset text2 ; hands the address of the firs char of text2
call WriteString ; prints out text2
call Crlf
call Crlf
mov edx, offset text3 ;hands the address of the firs char of text3
call WriteString ;prints out text3
call Crlf
mov esi,OFFSET Array1 ; puts the offset of array in esi
mov ecx,arraySyze ;6
mov ebx,TYPE Array1
call DumpMem
call Crlf
mov esi,OFFSET Array2 ; puts the offset of array in esi
mov ecx,arraySyze ; 6
mov ebx,TYPE Array1
call DumpMem
mov eax,0
swapLoop:
mov ebx, index ;moves index1 to ebx
;here i use the registers to add 8 in to the stack addresses
INVOKE CountNearMatches, ADDR[Array1 + ebx], ADDR[Array2 + ebx], diff
add ebx, 4 ;adding 4 to ebx
mov index, ebx ;putting ebx back in to index1
loop swapLoop
call Crlf
mov edx, offset text4 ;hands the address of the firs char of text4
call WriteString ;prints out text4
call WriteInt
call Crlf
call Crlf
call WaitMsg ; Press any key to contineu...
exit
main ENDP
; ***************************************
; This is where the magic happnes!
; This function gets its parameters from
; the stack and counts the near mathches
; from the two arrays...
; ***************************************
CountNearMatches PROC USES ebx edx esi edi,
arr1:PTR SDWORD, ;points to the first array
arr2:PTR SDWORD, ;points to the second array
diff3:DWORD ;gets the diff from the stack
;-------------------------------------------------------
mov eax,[arr1]
mov ebx,[arr2]
mov edx, diff3
sub eax,ebx
ret
CountNearMatches ENDP
END main
【问题讨论】:
-
我假设它在特定行上给你那个错误???
-
您收到的完整错误消息是什么?您使用什么命令来组装此文件?
-
感谢您的回答..我是组装新手...我使用 VS 组装文件,它在文件底部的原型定义的第一行给出了错误- -- CountNearMatches PROC 使用 eax esi edi,
-
我得到的错误是第 71 行的“错误 A2071:初始化器幅度对于指定大小而言太大”
-
我无法重现该错误。至少
PROTO声明CountNearMatches和PROC标头不匹配。