include	clib.inc

PPROC	strstr, S1:DPTR, S2:DPTR
	push	ds
	push	si
	push	di
	MLES	di,S1
	MLDS	si,S2
	xor	al,al
	cmp	al,[si]
	je	strstr_05
    strstr_00:
	mov	ah,[si]
    strstr_01:
	mov	al,es:[di]
	test	al,al
	jz	strstr_05
	inc	di
	cmp	al,ah
	jne	strstr_01
	mov	bx,di
	inc	si
    strstr_02:
	mov	al,[si]
	test	al,al
	jz	strstr_03
	cmp	es:[bx],al
	jne	strstr_03
	inc	si
	inc	bx
	jmp	strstr_02
	dec	si
    strstr_03:
	xor	al,al
	cmp	[si],al
	mov	si,word ptr S2
	jne	strstr_00
	mov	dx,es
	mov	ax,di
	dec	ax
    strstr_04:
	pop	di
	pop	si
	pop	ds
	ret
    strstr_05:
	xor	ax,ax
	cwd
	jmp	strstr_04
PEND	strstr

	END
