INCLUDE Irvine32.inc
.data
expr BYTE 64 DUP(0) ;; Only characters ‘(’ and ‘)’ allowed
depth WORD 0
prompt1 BYTE "Correct", 0
prompt2 BYTE "Incorrect", 0
.code
main PROC
call Clrscr
mov edx, OFFSET expr
mov ecx, (SIZEOF expr) - 1
call ReadString
mov esi, OFFSET expr
mov ecx, eax
L1: cmp BYTE PTR [esi], '('
jne L2 push eax
call increment
jmp L3
L2: cmp depth, 0
je ERR
pop eax
cmp al, BYTE PTR [esi]
jne ERR
dec depth
L3: inc esi
loop L1
cmp depth, 0
jne ERR
mov edx, OFFSET prompt1
call WriteString
jmp L4
ERR: mov edx, OFFSET prompt2
call WriteString
L4: exit
main ENDP
increment PROC ; This procedure is not really required.
pushad ; It is used to demonstrate the use of
mov cx, depth ; PUSHAD and POPAD.
inc cx
mov depth, cx
popad
ret
increment ENDP
END main
|
|