	.even
/"fndindex" looks for a job no. index in index file
/inputs:
/	r5 pts to address of no. being looked for
/outputs:
/	temp, ... , temp+12 contain index if found
/	r0 = byte offset if found; empty slot offset if not found
/calling sequence:
/	jsr	r5,fndindex
/	number
/	success_address
/	failure_address
/"sys tell" not used because it doesn't work properly
fndindex:
	mov	r1,-(sp)		/save regs
	mov	r2,-(sp)
	clr	r1
	clr	r2
	mov	(r5)+,r0
	mov	r0,4f
	add	$2,r0
	mov	r0,4f+2
	mov	ri,r0
	sys	seek; 0; 0		/position at beginning "f.index"
0:
	inc	r1
	mov	ri,r0
	sys	read; temp; 12.		/read an index entry
	tst	r0			/end file?
	bne	1f			/branch if not
	tst	(r5)+			/inc over success_address
	tst	r2			/empty slot encountered?
	beq	3f			/branch if not
	mov	r2,r1
	br	3f
1:
	cmp	temp+6,*4f+2
	bne	2f
	cmpb	temp+4,*4f
	beq	3f
2:
	tst	temp+6
	bne	0b
	tstb	temp+4
	bne	0b
	mov	r1,r2			/store index of free slot
	br	0b
3:
	dec	r1
	mov	r1,mq
	mov	$12.,mul
	mov	mq,r0
	mov	(sp)+,r2		/restore regs
	mov	(sp)+,r1
	mov	(r5),r5
	rts	r5			/return
4:
	.=.+2				/storage for address of no.
	.=.+2



ioerror:
	movb	(r5)+,1f+11.
	movb	(r5)+,1f+12.
	jsr	r5,mesg
1:
	<3IO ERROR   4\n\0>
	.even
	4



	.even
/"putindex" writes current "j.index" entry to index file
putindex:
	jsr	r5,fndindex		/find slot
	j.number
	0f
	0f
0:
	mov	r0,j.index+2.		/move index slot ptr.
					/to job index entry
	mov	r0,0f			/move index slot ptr.
	mov	wi,r0
	sys	seek; 0:..; 0		/seek index slot
	sys	write; j.index; 12.	/write index entry to slot
	rts	r5			/return


	.even
nosave:
	clrb	cflag			/reset changed core flag
	rts	r5			/return
flengths:
	.=.+14.
slchar:
	<\\>
orchar:
	<||>
