装配错误初始值设定值对于指定大小来说太大

assembly error initializer magnitude too large for specified size

我修复了这个错误,但现在有人可以建议一种方法让 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

我想通了.. 现在它实际上计算了所有接近的匹配项,不确定这是否是最好的方法,但它确实有效。 这是我的想法

    INCLUDE Irvine32.inc

CountNearMatches PROTO,                                  ; procedure prototype
        arr1:PTR SDWORD,
        arr2:PTR SDWORD,
        diff3:DWORD,
        aSize:DWORD

.data

        arraySize DWORD 6
        diff DWORD 3
        index DWORD  0                                                          ;var to use as the first index
       count DWORD 0
        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 text1
        call WriteString                                                                ; prints out text1
        call Crlf
        call Crlf

        mov edx, offset text3                                                   ;hands the address of the firs char of text1
        call WriteString                                                                ;prints out text1
        call Crlf

        mov  esi,OFFSET Array1                                                  ; puts the offset of array in esi
        mov  ecx,arraySize                                                                      ; count = 6
        mov  ebx,TYPE Array1                                                   
        call DumpMem
        call Crlf

        mov  esi,OFFSET Array2                                                  ; puts the offset of array in esi
        mov  ecx,arraySize                                                                      ; count = 6
        mov  ebx,TYPE Array1                                                   
        call DumpMem

        mov eax,0

        ;here i use the registers to add 8 in to the stack addresses
        INVOKE CountNearMatches, ADDR Array1, ADDR Array2, diff, arraySize

        call Crlf

        mov edx, offset text4                                                   ;hands the address of the firs char of text1
        call WriteString                                                                ;prints out text1

        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
        aSize:DWORD

;-------------------------------------------------------
        mov edx, 0                                              ;index
        mov ecx, aSize
myLoop:

        mov esi, arr1
        mov edi, arr2
        mov eax, [esi]
        mov ebx, [edi]

        sub eax,ebx
        cmp eax,diff3
        JLE myCount
       add arr1, 4
       add arr2, 4
        loop myLoop
myCount:
    inc count
    add arr1, 4
    add arr2, 4
    loop myLoop
    mov eax, count

    ret
CountNearMatches ENDP

END main