#
# xqmatch.s - fast pattern matcher for CHEF editor
#
	.text
	.globl	_bcplgi
#
	.globl	_xqmatch
_xqmatch:
#
	jbr	2f			# skip chain
#
1:	pushl	fp			# standard entry sequence
	addl3	$248,sp,fp
	movq	(sp)+,-4(fp)
	addl2	$212,sp			# parameters on top of stack
	popr	$63			# parameters to registers as below
#
# r0  =  p2
# r1  =  p1
# r2  =  patn
# r3  =  t2
# r4  =  t1
# r5  =  line
#
	subl2	r1,r0			# form length of object string
	subl2	r4,r3			# form length of source string
	addl2	r0,r3
	ashl	$2,r2,r2		# form object address
	addl2	r1,r2
	ashl	$2,r5,r5		# form source address
	addl3	r5,r0,r6		# save for final offset calculation
	addl2	r4,r5
	matchc	r0,(r2),r3,(r5)		# look for object in source
	jnequ	5f			# j if not found
	subl3	r6,r3,r0		# yield offset of match in line
#	incl	r0
4:	movl	(sp)+,fp		# standard exit code
	rsb
5:	mnegl	$1,r0			# yield -1 for no match
	jbr	4b
#
# Global initialisation
#
2:	jsb	_bcplgi
	.long	142,1b
	.long	-1
	jbr	3f			# avoid loader alignment problems
	.align	2
3:
#
# End of file xqmatch.s
#
