	pure
* list pieces controlling a square

	entry	attack

	extrn	dir,board
	extrn	attacv

none	equ	x'14e5'			012345
r0	equ	0
r1	equ	1
r2	equ	2
r3	equ	3
r4	equ	4
r5	equ	5
r6	equ	6
sp	equ	7
rf	equ	15

uleft	equ	x'0820'
uright	equ	x'0804'
dleft	equ	x'0120'
dright	equ	x'0104'
left	equ	x'0020'
right	equ	x'0004'
up	equ	x'0800'
down	equ	x'0100'
u2r1	equ	x'0c04'
u1r2	equ	x'0806'
d1r2	equ	x'0106'
d2r1	equ	x'0184'
d2l1	equ	x'01a0'
d1l2	equ	x'0130'
u1l2	equ	x'0830'
u2l1	equ	x'0c20'
rank2	equ	x'0080'
rank7	equ	x'0400'

attack	equ	*
	sis	sp,4
	l	r6,4(sp)
	slls	r6,1
	la	r4,attacv


	bal	r5,patt
	   dc	z(u2r1)
	   dc	z(-30)
	   dc	z(2),z(-2)
	bal	r5,patt
	   dc	z(u1r2)
	   dc	z(-12)
	   dc	z(2),z(-2)
	bal	r5,patt
	   dc	z(d2r1)
	   dc	z(34)
	   dc	z(2),z(-2)
	bal	r5,patt
	   dc	z(d2l1)
	   dc	z(30)
	   dc	z(2),z(-2)
	bal	r5,patt
	   dc	z(d1l2)
	   dc	z(12)
	   dc	z(2),z(-2)
	bal	r5,patt
	   dc	z(u1l2)
	   dc	z(-20)
	   dc	z(2),z(-2)
	bal	r5,patt
	   dc	z(u2l1)
	   dc	z(-34)
	   dc	z(2),z(-2)

	bal	r5,satt
	   dc	z(uleft),z(-18)
	   dc	z(1)
	   dc	z(3),z(-3),z(5),z(-5)
	bal	r5,satt
	   dc	z(uright),z(-14)
	   dc	z(1)
	   dc	z(3),z(-3),z(5),z(-5)
	bal	r5,satt
	   dc	z(dleft),z(14)
	   dc	z(-1)
	   dc	z(3),z(-3),z(5),z(-5)
	bal	r5,satt
	   dc	z(dright),z(18)
	   dc	z(-1)
	   dc	z(3),z(-3),z(5),z(-5)
	bal	r5,satt
	   dc	z(up),z(-16)
	   dc	z(none)
	   dc	z(4),z(-4),z(5),z(-5)
	bal	r5,satt
	   dc	z(left),z(-2)
	   dc	z(none)
	   dc	z(4),z(-4),z(5),z(-5)
	bal	r5,satt
	   dc	z(right),z(2)
	   dc	z(none)
	   dc	z(4),z(-4),z(5),z(-5)
	bal	r5,satt
	   dc	z(down),z(16)
	   dc	z(none)
	   dc	z(4),z(-4),z(5),z(-5)

	lhi	r0,0
	sth	r0,0(r4)
	ais	sp,4
	br	rf

patt	equ	*
	lh	r0,dir(r6)
	nh	r0,0(r5)
	bne	patt1
	lr	r1,r6
	ah	r1,2(r5)
	ais	r5,4
	bal	r3,look
	bal	r3,look
	b	0(r5)
patt1	equ	*
	b	8(r5)

satt	equ	*
	lr	r2,r5
	lh	r0,dir(r6)
	nh	r0,0(r5)
	bne	satt1
	lr	r1,r6
	ah	r1,2(r5)
	ais	r5,4
	bal	r3,look		pawn
	lr	r1,r6
satt2	equ	*
	lr	r5,r2
	lh	r0,dir(r1)
	nh	r0,0(r5)
	bne	satt1
	ah	r1,2(r5)
	ais	r5,6
	lh	r0,board(r1)
	be	satt2
	st	r4,0(sp)
	bal	r3,look
	bal	r3,look
	bal	r3,look
	bal	r3,look
	c	r4,0(sp)
	bne	satt2
satt1	equ	*
	b	14(r2)

look	equ	*
	lh	r0,0(r5)
	ch	r0,board(r1)
	bne	look1
	sth	r0,0(r4)
	ais	r4,2
look1	equ	*
	ais	r5,2
	br	r3

	end
