/ sym1 -- 3d tic-tac-toe

sym:
	mov	r1,-(sp)
	mov	r2,-(sp)
	mov	$ilist,r1
	mov	$board,r2
1:
	mov	(r2)+,(r1)+
	cmp	r1,$ilist+128.
	bne	1b

	mov	$-64.,which

1:
	add	$64.,which
	cmp	which,$64.*192.
	beq	1f
2:
	clr	r1
	mov	$-1,r2

2:
	mov	r1,r0
	asr	r0
	add	which,r0
	movb	map(r0),r0
	cmp	board(r1),board(r0)
	beq	4f
	inc	r2
	bgt	1b
	tst	board(r0)
	bne	4f
	cmp	board(r1),$8.
	bne	1b
	mov	r0,r3

4:
	tst	(r1)+
	cmp	r1,$128.
	bne	2b

	tst	r2
	bge	2f
	clr	r0
4:
	mov	r0,r1
	asr	r1
	add	which,r1
	movb	map(r1),r1
	cmp	r0,r1
	bge	3f
	tst	ilist(r0)
	bne	3f
	tst	board(r0)
	bne	3f
	inc	ilist(r1)
3:
	tst	(r0)+
	cmp	r0,$128.
	bne	4b
	br	1b

2:
	inc	ilist(r3)
	br	1b

1:
	mov	$ilist,r0
	clr	r1
	clr	nilist
1:
	tst	ilist(r1)
	bne	2f
	mov	r1,(r0)+
	inc	nilist
2:
	tst	(r1)+
	cmp	r1,$128.
	bne	1b
qq:
	asl	nilist
	mov	(sp)+,r2
	mov	(sp)+,r1
	rts	r5

