riskitall69
riskitall69

Reputation: 1

MASM error: A2032 error Specifed size

This program is supposed to compare an array of five elements to the min and max values for each element in the array. I'm not sure why that when I compare the array to the max array and min array I get this error

1>......\Users\ross\Desktop\chapter6HW.asm(97): error A2032: invalid......\Users\ross\Desktop\chapter6HW.asm(99)r specified size

Here's my code. I have marked where the error is with ** ** .

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

Upvotes: 0

Views: 323

Answers (1)

Michael
Michael

Reputation: 58427

You can't compare a memory operand with another memory operand like that. You'll have to use a register as an intermediary:

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

Another potential issue is that your Display routine doesn't seem to preserve the original value of esi, which Validate_PIN relies on.

Upvotes: 2

Related Questions