How can I validate the phone number? Is it validate using loop? And why it shows error for the [phone+esi].
And also how to validate the username if I want to make sure all the input is characters
INCLUDE Irvine32.inc
.data
tryDigit BYTE 'Enter 10 digits here: ',0
MAX = 10
phone BYTE MAX+1 dup (?)
yesDigit BYTE 'Digit',0
notDigit BYTE 'Not Digit',0
.code
MAIN PROC
mov edx,0
mov eax,0
mov edx, OFFSET tryDigit
call WriteString
mov edx, OFFSET phone
mov ecx, MAX
call ReadString
call Crlf
;Validate phone number
L1:
mov ecx, LENGTHOF phone
mov esi, OFFSET phone
mov al, [phone+esi]
call IsDigit
jnz errorMsg
mov edx, OFFSET yesDigit
call WriteString
call Crlf
inc esi
Loop L1
errorMsg:
mov edx, OFFSET notDigit
call WriteString
call Crlf
exit
MAIN ENDP
END MAIN
New contributor
Vient is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.