MASM错误:A2032错误指定的大小

时间:2015-11-13 19:42:46

标签: arrays assembly x86 masm irvine32

该程序应该将五个元素的数组与数组中每个元素的最小值和最大值进行比较。我不确定为什么当我将数组与max array和min数组进行比较时,我得到了这个错误

  

1> ...... \ Users \ ross \ Desktop \ chapter6HW.asm(97):错误A2032:   无效...... \ Users \ ross \ Desktop \ chapter6HW.asm(99)r指定大小

这是我的代码。我已使用** **标记错误的位置。

INCLUDE Irvine32.inc

.data
str1 BYTE "Invalid",0
str2 BYTE "Valid", 0
str3 BYTE "The PIN under Validation is:",0
minArr BYTE 5,2,4,1,3
maxArr BYTE 9,5,8,4,6

arr1 BYTE 6,4,5,3,5
arr2 BYTE 1,4,5,3,5
arr3 BYTE 8,4,5,2,5
arr4 BYTE 5,4,9,2,6

.code
main PROC
call Clrscr

mov esi,OFFSET arr1
call Display
call Validate_PIN

cmp eax,0

je L1

mov edx,OFFSET str1
call WriteString
call Crlf

L1:
mov edx,OFFSET str2
call WriteString
call Crlf
call Crlf

mov esi,OFFSET arr2

call Display
call Validate_PIN

cmp eax,0
je L2
mov edx,OFFSET str1
call WriteString
call Crlf

L2:
mov edx,OFFSET str2

call WriteString
call Crlf
call Crlf
mov esi,OFFSET arr3

call Display

call Validate_PIN

cmp eax,0

je l3

mov edx,OFFSET str1
call WriteString
call Crlf

L3:
mov edx,OFFSET str2
call WriteString
call Crlf
call Crlf

mov esi,OFFSET arr4
call Display
call Validate_PIN

cmp eax,0
je L4
mov edx,OFFSET str1
call WriteString
call Crlf
L4:
mov edx,OFFSET str2
call WriteString
call Crlf
call Crlf
exit 
main ENDP

Validate_PIN PROC
mov edi,0
mov ecx,5

L1:
**cmp [esi],minArr[edi]**
jb L2
**cmp [esi],maxArr[edi]**
ja L2
inc esi
inc edi
cmp edi,5
je L3
loop L1
L2:
mov eax,edi
inc eax
jmp L4
L3:
mov eax,0
L4:
ret
Validate_PIN ENDP

Display PROC
mov edx,OFFSET str3
call WriteString
mov ecx,5
L1:
mov eax,[esi]
call WriteDec
inc esi
loop L1
call Crlf
ret
Display ENDP

End main

1 个答案:

答案 0 :(得分:2)

您无法将内存操作数与另一个内存操作数进行比较。您必须使用注册作为中间人:

mov al,[esi]
cmp al,minArr[edi]
jb L2
cmp al,maxArr[edi]

另一个潜在的问题是,您的Display例程似乎没有保留esi所依赖的Validate_PIN的原始值。