You'd normally want to do a search like this using rep scasb
:
test1 proc
mov P, 0ffffh ; for now, assume it won't be found
mov al, V ; what we're going to look for
mov di, offset array_b ; where we're going to look
mov cx, size array_b ; how many items to search
repnz scasb ; do the search
jnz done ; Z flag clear = not found
sub di, offset array_b ; found: compute offset into array_b
mov P, di ; and save it
done:
ret