%{
/*
 * c code tables-- compile to register
 *
 * This file is part of BKUNIX project, which is distributed
 * under the terms of the GNU General Public License (GPL).
 * See the accompanying file "COPYING" for more details.
 */

struct table regtab[] = {
	{106,cr106},
	{30,cr70},
	{31,cr70},
	{32,cr32},
	{33,cr32},
	{37,cr37},
	{38,cr37},
	{98,cr100},
	{99,cr100},
	{80,cr80},
	{40,cr40},
	{41,cr40	/* - like + */},
	{42,cr42},
	{43,cr43},
	{14,cr14},
	{44,cr43},
	{45,cr45},
	{46,cr40},
	{55,cr40},
	{48,cr40},
	{49,cr49},
	{70,cr70},
	{71,cr70},
	{72,cr72},
	{73,cr73},
	{74,cr74},
	{75,cr75},
	{76,cr72},
	{78,cr78},	/* |= */
	{85,cr78},	/* &= */
	{79,cr79},
	{102,cr102},
	{51,cr51},
	{52,cr52},
	{56,cr56},
	{57,cr57},
	{58,cr58},
	{59,cr59},
	{91,cr91},
	{82,cr82},
	{83,cr82},
	{84,cr82},
	{86,cr86},
	{87,cr86},
	{88,cr86},
	{16,cr16},
	{92,cr92},
	{17,cr43},
	{18,cr74},
	{109,cr109},
	{117,cr117},
	{118,cr117},
	{119,cr119},
	{120,cr119},
	{107,cr107},
	{121,cr121},
	{122,cr121},
	{123,cr121},
	{124,cr124},
	{125,cr124},
	{126,cr124},
	{127,cr127},
	{128,cr128},
	{129,cr129},
	{0}
};
%}

/* goto */
cr102:
%a,n
	jmp	A1

%n*,n
	F*
	jmp	#1(R)

/* call */
cr100:
%a,n
	jsr	pc,IA1

%n*,n
	F*
	jsr	pc,#1(R)

%n,n
	F
	jsr	pc,(R)

/* addressible */
cr106:
%z,n
	clr	R

%zf,n
	clrf	R

%aub,n
	clr	R
	bisb	A1,R

%a,n
%ad,n
	movB1	A1,R

%af,n
	movof	A1,R

%nub*,n
	F*
	movb	#1(R),R
	bic	$!377,R

%n*,n
%nd*,n
	F*
	movB1	#1(R),R

%nf*,n
	F*
	movof	#1(R),R

%al,n
%aul,n
	mov	A1+,R+
	mov	A1,R

%nl*,n
%nul*,n
	F*
	mov	#1+2(R),R+
	mov	#1(R),R

%n,n
	F

/* ++,-- postfix */
cr32:
%a,1
	movB1	A1',R
	I'B1	A1''

%aw,n
	mov	A1',R
	I	A2,A1''

%aub,n
	clr	R
	bisb	A1',R
	I'b	A1''

%e*,1
	F1*
	movB1	#1(R1),R
	I'B1	#1(R1)

%n*,1
	F*
	movB1	#1(R),-(sp)
	I'B1	#1(R)
	movB1	(sp)+,R

%ew*,n
	F1*
	mov	#1(R1),R
	I	A2,#1(R1)

%eub*,n
	F1*
	clr	R
	bisb	#1(R1),R
	I'b	#1(R1)

%nw*,n
	F*
	mov	#1(R),-(sp)
	I	A2,#1(R)
	mov	(sp)+,R

%nub*,n
	F*
	movb	(R),-(sp)
	I'b	(R)
	clr	R
	bisb	(sp)+,R

%al,1
%aul,1
	F
	I	$1,A1+
	V	A1

%el*,1
%eul*,1
	F1*
	mov	#1+2(R1),R+
	mov	#1(R1),R
	I	$1,#1+2(R1)
	V	#1(R1)

%nl*,1
%nul*,1
	F*
	mov	#1+2(R),-(sp)
	mov	#1(R),-(sp)
	I	$1,#1+2(R)
	V	#1(R)
	mov	(sp)+,R
	mov	(sp)+,R+

/* - unary, ~ */
cr37:
%n,n
%nf,n
	F
	IBF	R

%nl,n
%nul,n
	F
	I	R
	I	R+
	V	R

/* = */
cr80:
%a,n
%ad,nf
	S
	movB1	R,A1

%aub,n
	S
	movB1	R,A1
	bic	$!377,R

%af,nf
	S
	movfo	R,A1

%nd*,af
	F*
	S
	movf	R,#1(R)

%n*,aw
	F*
	movB1	A2,#1(R)
	movB1	#1(R),R

%nf*,af
	F*
	S
	movfo	R,#1(R)

%n*,e
	F*
	S1
	movB1	R1,#1(R)
	movB1	R1,R

%nub*,e
	F*
	S1
	movB1	R1,#1(R)
	clr	R
	bisb	R1,R

%ed*,nf
	S
	F1*
	movf	R,#1(R1)

%ef*,nf
	S
	F1*
	movfo	R,#1(R1)

%n*,n
%nd*,nf
	FS*
	S
	movB1	R,*(sp)+

%nub*,n
	FS*
	S
	movB1	R,*(sp)+
	bic	$!377,R

%nf*,nf
	FS*
	S
	movfo	R,*(sp)+

%al,nl
%al,nul
%aul,nl
%aul,nul
	S
	mov	R+,A1+
	mov	R,A1

%el*,nl
%el*,nul
%eul*,nl
%eul*,nul
	S
	F1*
	mov	R+,2+#1(R1)
	mov	R,#1(R1)

%nl*,nl
%nl*,nul
%nul*,nl
%nul*,nul
	FS*
	S
	mov	R,*(sp)
	add	$2,(sp)
	mov	R+,*(sp)+

/* field assign, value in reg. */
cr16:
%a,n
	S
	bicB1	Z,A1'
	bisB1	R,A1''

%e*,n
%	[fas1]

%n*,n
	SS
	F*
	bicB1	Z,#1(R)
	bisB1	(sp),#1(R)
	mov	(sp)+,R

/* +, -, |, &~, << */
cr40:
%n,z
	F

%n,1
	F
	I'	R

%[add1:]
%n,aw
%nf,ad
	F
	IB2	A2,R

%[add2:]
%n,ew*
%nf,ed*
	F
	S1*
	IB2	#2(R1),R

%[add3:]
%n,e
%nf,ef
	F
	S1
	IBF	R1,R

%[add4:]
%n,nw*
%nf,nd*
	SS*
	F
	IB2	*(sp)+,R

%[add5:]
%n,n
%nf,nf
	SS
	F
	IBF	(sp)+,R

%nl,c
%nl,au
%nul,c
%nul,au
	F
	I	A2,R+
	V	R

%nl,eu
%nul,eu
	F
	S1
	I	R1,R+
	V	R

%nl,al
%nl,aul
%nul,al
%nul,aul
	F
	I	A2,R
	I	A2+,R+
	V	R

%[addl1:]
%nl,el
%nl,eul
%nul,el
%nul,eul
	F
	S1
	I	R1+,R+
	V	R
	I	R1,R

%[addl2:]
%nl,nl
%nl,nul
%nul,nl
%nul,nul
	SS
	F
	I	(sp)+,R
	I	(sp)+,R+
	V	R

/* ^ -- xor */
cr49:
%n,e
%	[add3]

%n,n
	FS
	S
	xor	R,(sp)
	mov	(sp)+,R

%nl,el
%nl,eul
%nul,el
%nul,eul
%	[addl1]

%nl,nl
%nl,nul
%nul,nl
%nul,nul
	SS
	F
	I	R,(sp)
	mov	(sp)+,R
	I	R+,(sp)
	mov	(sp)+,R+

/* >> (all complicated cases taken care of by << -) */
cr45:
%n,1
	F
	asr	R

/* * -- R must be odd on integers */
cr42:
%n,aw
%nf,ad
%	[add1]

%n,ew*
%nf,ed*
%	[add2]

%n,e
%nf,ef
%	[add3]

%n,n
%nf,nf
%	[add5]

/* / and >> R must be odd on integers */
cr43:
%n,aw
	F
	T
	I	A2,R-

%n,ew*
	F
	T
	S1*
	I	#2(R1),R-

%n,e
	F
	T
	S1
	I	R1,R-

%n,n
	SS
	F
	T
	I	(sp)+,R-

%nf,ad
%	[add1]

%nf,ed*
%	[add2]

%nf,ef
%	[add3]

%nf,nf
%	[add5]

/* PTOI */
cr14:
%nl,a
%nul,a
	F!
	div	A2,R

/* =+, =- */
cr70:
%[addq1:]
%aw,aw
	I	A2,A1'
	mov	A1'',R

%[addq20:]
%aub,aw
	clr	R
	bisb	A1',R
	I	A2,R
	movb	R,A1''
	bic	$!377,R

%[addq1a:]
%a,aw
%ad,ad
	movB1	A1',R
	IBF	A2,R
	movB1	R,A1''

%[addq2:]
%aw,nw*
	S*
	I	#2(R),A1'
	mov	A1'',R

%[addq3:]
%aw,n
	S
	I	R,A1'
	mov	A1'',R

%[addq21:]
%aub,n
	SS
	clr	R
	bisb	A1',R
	I	(sp)+,R
	movb	R,A1''
	bic	$!377,R

%[addq4:]
%ew*,nw*
	S*
	F1*
	I	#2(R),#1(R1)
	mov	#1(R1),R

%[addq4a:]
%ad,ef
	movf	A1',R
	S1
	IBF	R1,R
	movf	R,A1''

%[addq5:]
%a,n
%ad,nf
	SS
	movB1	A1',R
	IBF	(sp)+,R
	movB1	R,A1''

%[addq6:]
%af,nf
	SS
	movof	A1',R
	IBF	(sp)+,R
	movfo	R,A1''

%[addq7:]
%ew*,n
	S
	F1*
	I	R,#1(R1)
	mov	#1(R1),R

%[addq8:]
%nw*,n
	SS
	F*
	I	(sp)+,#1(R)
	mov	#1(R),R

%[addq9:]
%n*,n
	FS*
	SS
	movB1	*2(sp),R
	IBF	(sp)+,R
	movB1	R,*(sp)+

%[addq22:]
%nub*,n
	FS*
	SS
	clr	R
	bisb	*2(sp),R
	I	(sp)+,R
	movb	R,*(sp)+
	bic	$!377,R

%[addq9a:]
%nd*,nf
	SS
	F*
	movB1	#1(R),R
	IBF	(sp)+,R
	movB1	R,#1(R)

%[addq10:]
%nf*,nf
	SS
	F*
	movof	#1(R),R1
	IBF	(sp)+,R1
	movfo	R1,#1(R)
	movf	R1,R

%[addq11:]
%al,c
%aul,c
	I	A2,A1+
	V	A1
	F

%[addq12:]
%al,al
%al,aul
%aul,al
%aul,aul
	I	A2+,A1+
	V	A1
	I	A2,A1
	F

%[addq13:]
%al,nl
%al,nul
%aul,nl
%aul,nul
	S
	I	R+,A1+
	V	A1
	I	R,A1
	F

%[addq14:]
%nl*,c
%nul*,c
	F*
	I	A2,#1+2(R)
	V	#1(R)
	mov	#1+2(R),R+
	mov	#1(R),R

%[addq15:]
%nl*,al
%nl*,aul
%nul*,al
%nul*,aul
	F*
	I	A2+,#1+2(R)
	V	#1(R)
	I	A2,#1(R)
	mov	#1+2(R),R+
	mov	#1(R),R

%[addq16:]
%nl*,nl
%nl*,nul
%nul*,nl
%nul*,nul
	SS
	F*
	I	(sp)+,#1(R)
	I	(sp)+,#1+2(R)
	V	#1(R)
	mov	#1+2(R),R+
	mov	#1(R),R

/* *=, <<= (for integer multiply, R must be odd) */
cr72:
%a,aw
%ad,ad
%	[addq1a]

%ad,ef
%	[addq4a]

%a,n
%ad,nf
%	[addq5]

%af,nf
%	[addq6]

%aub,aw
%	[addq20]

%aub,n
%	[addq21]

%n*,n
%	[addq9]

%nub*,n
%	[addq22]

%nd*,nf
%	[addq9a]

%nf*,nf
%	[addq10]

/* =/ ;  R must be odd on integers */
cr73:
%a,aw
	movB1	A1',R
	V	R-
	IBF	A2,R-
	movB1	R-,A1''

%a,n
	SS
	movB1	A1',R
	V	R-
	I	(sp)+,R-
	movB1	R-,A1''

%aub,n
	SS
	clr	R
	bisB1	A1',R
	V	R-
	I	(sp)+,R-
	movB1	R-,A1''
	bic	$!377,R-

%e*,n
	SS
	F1*
	movB1	#1(R1),R
	V	R-
	I	(sp)+,R-
	movB1	R-,#1(R1)

%n*,n
	FS*
	SS
	movB1	*2(sp),R
	V	R-
	I	(sp)+,R-
	movB1	R-,*(sp)+

%nub*,n
	FS*
	SS
	clr	R
	bisB1	*2(sp),R
	V	R-
	I	(sp)+,R-
	movB1	R-,*(sp)+
	bic	$!377,R-

%ad,ad
%	[addq1a]

%ad,ef
%	[addq4a]

%ad,nf
%	[addq5]

%af,nf
%	[addq6]

%nd*,nf
%	[addq9a]

%nf*,nf
%	[addq10]

/* >>= and =mod; R must be odd on integers */
cr74:
%a,aw
	movB1	A1',R
	V	R-
	I	A2,R-
	movB1	R,A1''

%a,n
	SS
	movB1	A1',R
	V	R-
	I	(sp)+,R-
	movB1	R,A1''

%aub,n
	SS
	clr	R
	bisB1	A1',R
	V	R-
	I	(sp)+,R-
	movB1	R,A1''
	bic	$!377,R

%e*,n
	SS
	F1*
	movB1	#1(R1),R
	V	R-
	I	(sp)+,R-
	movB1	R,#1(R1)

%n*,n
	FS*
	SS
	movB1	*2(sp),R
	V	R-
	I	(sp)+,R-
	movB1	R,*(sp)+

%nub*,n
	FS*
	SS
	clr	R
	bisB1	*2(sp),R
	V	R-
	I	(sp)+,R-
	movB1	R,*(sp)+
	bic	$!377,R

/* =^ -- =xor */
cr79:
%aw,n
%	[addq3]

%ab,n
	SS
	movb	A1',R
	xor	R,(sp)
	mov	(sp)+,R
	movb	R,A1''

%aub,n
	SS
	movb	A1',R
	xor	R,(sp)
	clr	R
	bisb	(sp)+,R
	movb	R,A1''

%n*,n
	FS*
	movB1	*(sp),-(sp)
	S
	xor	R,(sp)
	movB1	(sp)+,R
	movB1	R,*(sp)+

%nub*,n
	FS*
	clr	-(sp)
	bisb	*2(sp),(sp)
	S
	xor	R,(sp)
	mov	(sp)+,R
	movb	R,*(sp)+
	bic	$!377,R

/* =>> (all complicated cases done by =<< -) */
cr75:
%a,1
	asrB1	A1'
	movB1	A1'',R

%n*,1
	F*
	asrB1	#1(R)
	movB1	#1(R),R

/* =|, =&~ */
cr78:
%aw,aw
%	[addq1]

%aub,a
	IBE	A2,A1'
	clr	R
	bisb	A1'',R

%a,aw
%ad,ad
%	[addq1a]

%aw,nw*
%	[addq2]

%aw,n
%	[addq3]

%aub,n
	SS
	IBE	(sp)+,A1'
	clr	R
	bisb	A1'',R

%ew*,nw*
%	[addq4]

%ad,ef
%	[addq4a]

%a,n
%ad,nf
%	[addq5]

%af,nf
%	[addq6]

%ew*,n
%	[addq7]

%nw*,n
%	[addq8]

%n*,n
%	[addq9]

%nub*,n
	FS*
	SS
	IBE	(sp),*2(sp)
	tst	(sp)+
	clr	R
	bisb	*(sp)+,R

%nd*,nf
%	[addq9a]

%nf*,nf
%	[addq10]

%al,c
%aul,c
%	[addq11]

%al,al
%al,aul
%aul,al
%aul,aul
%	[addq12]

%al,nl
%al,nul
%aul,nl
%aul,nul
%	[addq13]

%nl*,c
%nul*,c
%	[addq14]

%nl*,al
%nl*,aul
%nul*,al
%nul*,aul
%	[addq15]

%nl*,nl
%nl*,nul
%nul*,nl
%nul*,nul
%	[addq16]

/* << for longs */
cr91:
%nl,aw
%nul,aw
%	[add1]

%nl,ew*
%nul,ew*
%	[add2]

%nl,e
%nul,e
%	[add3]

%nl,nw*
%nul,nw*
%	[add4]

%nl,n
%nul,n
%	[add5]

/* >> for unsigned long */
cr128:
%nl,n
%nul,n
	SS
	F
	jsr	pc,I
	tst	(sp)+

/* >>= for unsigned long  */
cr129:
%n,n
	SS
	FS
	jsr	pc,I
	cmp	(sp)+,(sp)+

/* int -> float */
cr51:
%aw,n
	movif	A1,R

%nw*,n
	F*
	movif	#1(R),R

%n,n
	F
	movif	R,R

/* float, double -> int */
cr52:
%nf,n
	F
	movfi	R,R

/* double (float) to long */
cr56:
%nf,n
	F
	setl
	movfi	R,-(sp)
	mov	(sp)+,R
	mov	(sp)+,R+
	seti

/* long to double */
cr57:
%al,n
	setl
	movif	A1,R
	seti

%nl*,n
	F*
	setl
	movif	#1(R),R
	seti

%nl,n
	FS
	setl
	movif	(sp)+,R
	seti

/* unsigned long to float(double) */
cr127:
%aul,n
	mov	A1+,-(sp)
	mov	A1,-(sp)
	jsr	pc,I
	cmp	(sp)+,(sp)+

%nul*,n
	F*
	mov	#1+2(R),-(sp)
	mov	#1(R),-(sp)
	jsr	pc,I
	cmp	(sp)+,(sp)+

%nul,n
	FS
	jsr	pc,I
	cmp	(sp)+,(sp)+

/* integer to long */
cr58:
%eu,n
	F1!
	clr	R

%nu,n
	F
	mov	R,R1
	clr	R

%e,n
	F1!
	sxt	R

%n,n
	F
	mov	R,R1
	sxt	R

/* long to integer */
cr59:
%al,n
%aul,n
	mov	A1+,R

%nl*,n
%nul*,n
	F*
	mov	#1+2(R),R

/* *, /, remainder for longs. */
cr82:
%[l82:]
%nl,nl
%nl,nul
%nul,nl
%nul,nul
	SS
	FS
	jsr	pc,I
	add	$10,sp

/* *, /, rem for unsigned long */
cr121:
%nul,nl
%nl,nul
%nul,nul
%	[l82]

/* *=, /=, %= for unsigned long */
cr124:
%n,nl
%n,nul
%nl,n
%nul,n
%	[l86]

/* *=, /=, %= for longs */
/* Operands of the form &x op y, so stack space is known. */
cr86:
%[l86:]
%n,nl
%n,nul
	SS
	FS
	jsr	pc,I
	add	$6,sp

/* convert integer to character (sign extend) */
cr109:
%n,n
	F
	movb	R,R

/* divide, remainder for unsigned */
cr117:
%n,e
	F!
	S1!
	jsr	pc,I

%n,n
	SS
	F!
	mov	(sp)+,R1
	jsr	pc,I

/* /= mod for unsigned */
cr119:
%aw,e
%ab,e
	movB1	A1',R
	S1!
	jsr	pc,I
	movB1	R,A1''

%aub,e
	clr	R
	bisB1	A1',R
	S1!
	jsr	pc,I
	movb	R,A1''

%aw,n
%ab,n
	SS
	movB1	A1',R
	mov	(sp)+,R1
	jsr	pc,I
	movB1	R,A1''

%nw*,n
%nb*,n
	FS*
	S!
	mov	R,R1
	movB1	*(sp),R
	jsr	pc,I
	movB1	R,*(sp)+

%aub,n
	SS
	clr	R
	bisB1	A1',R
	mov	(sp)+,R1
	jsr	pc,I
	movB1	R,A1''

%nub*,n
	FS*
	S!
	mov	R,R1
	clr	R
	bisb	*(sp),R
	jsr	pc,I
	movB1	R,*(sp)+

/* (int *) - (int *) */
cr107:
%n,n
	F?
	ror	R

%{
/*
 * c code tables -- compile for side effects.
 * Also set condition codes properly (except for ++, --)
 */

struct table efftab[] = {
	{30,ci70},
	{31,ci70},
	{32,ci70},
	{33,ci70},
	{80,ci80},
	{70,ci70},
	{71,ci70	/* - like + */},
	{78,ci78},
	{79,ci79},
	{85,ci78},
	{75,ci75},
	{76,ci76},
	{16,ci16},
	{116,ci116},
	{0}
};
%}

/* = */
ci80:
%[move1:]
%a,z
%ad,zf
%aub,z
	I'B1	A1

%[move2:]
%n*,z
%nd*,zf
%nub*,z
	F*
	I'B1	#1(R)

%[move3:]
%a,aw
%ab,a
%ab,aub
%aub,a
%aub,ab
	IBE	A2,A1

%[move4:]
%ab,n*
%a,nw*
%aub,n*
	S*
	IBE	#2(R),A1

%[move5:]
%a,n
%aub,n
	S
	IB1	R,A1

%[move6:]
%n*,aw
%nb*,a
%nub*,a
	F*
	IBE	A2,#1(R)

%[move7:]
%n*,ew*
%nb*,e*
%nub*,e*
	F*
	S1*
	IBE	#2(R1),#1(R)

%[move8:]
%n*,e
%nub*,e
	F*
	S1
	IB1	R1,#1(R)

%[move9:]
%e*,nw*
%eb*,n*
%eub*,n*
	S*
	F1*
	IBE	#2(R),#1(R1)

%[move10:]
%e*,n
%eub*,n
	S
	F1*
	IB1	R,#1(R1)

%[move11:]
%n*,nw*
%nb*,n*
%nub*,n*
	FS*
	S*
	IBE	#2(R),*(sp)+

%[move12:]
%n*,n
%nub*,n
	FS*
	S
	IB1	R,*(sp)+

%aw,nf
	S
	movfi	R,A1

%ew*,nf
	S
	F1*
	movfi	R,#1(R1)

%al,z
%aul,z
	clr	A1
	clr	A1+

%nl*,z
%nul*,z
	F*
	clr	#1(R)
	clr	2+#1(R)

%[move13a:]
%al,aw
%aul,aw
	I	A2,A1+
	V	A1

%al,nw*
%aul,nw*
	S*
	mov	#2(R),A1+
	V	A1

%al,n
%aul,n
	S
	mov	R,A1+
	V	A1

%al,nf
%aul,nf
	S
	setl
	movfi	R,A1
	seti

%el*,nf
%eul*,nf
	S
	F1*
	setl
	movfi	R,#1(R1)
	seti

%[move13:]
%al,al
%al,aul
%aul,al
%aul,aul
	I	A2,A1
	I	A2+,A1+
	V	A1

%[move14:]
%al,nl*
%al,nul*
%aul,nl*
%aul,nul*
	S*
	I	#2(R),A1
	I	#2+2(R),A1+
	V	A1

%[move15:]
%al,nl
%al,nul
%aul,nl
%aul,nul
	S
	I	R,A1
	I	R+,A1+
	V	A1

%[move14a:]
%nl*,aw
%nul*,aw
	F*
	I	A2,#1+2(R)
	V	#1(R)

%[move16a:]
%nl*,al
%nl*,aul
%nul*,al
%nul*,aul
	F*
	I	A2+,#1+2(R)
	V	#1(R)
	I	A2,#1(R)

%[move16:]
%el*,nl
%el*,nul
%eul*,nl
%eul*,nul
	S
	F1*
	I	R+,#1+2(R1)
	V	#1(R1)
	I	R,#1(R1)

%nl*,n
%nul*,n
	SS
	F*
	mov	(sp)+,#1+2(R)
	V	#1(R)

%[move17:]
%nl*,nl
%nl*,nul
%nul*,nl
%nul*,nul
	SS
	F*
	I	(sp)+,#1(R)
	I	(sp)+,#1+2(R)
	V	#1(R)

/* =| and =& ~ */
ci78:
%a,a
%a,ab
%a,aub
%ab,a
%ab,ab
%ab,aub
%aub,a
%aub,ab
%aub,aub
%	[move3]

%aub,n
	S
	IBE	R,A1

%a,n
%	[move5]

%n*,aw
%nb*,a
%nub*,a
%	[move6]

%n*,ew*
%nb*,e*
%nub*,e*
%	[move7]

%n*,e
%	[move8]

%e*,nw*
%eb*,n*
%eub*,n*
%	[move9]

%e*,n
%	[move10]

%n*,nw*
%nb*,n*
%nub*,n*
%	[move11]

%n*,n
%	[move12]

%al,c
%al,au
%aul,c
%aul,au
%	[move13a]

%al,al
%al,aul
%aul,al
%aul,aul
%	[move13]

%al,nl*
%al,nul*
%aul,nl*
%aul,nul*
%	[move14]

%al,nl
%al,nul
%aul,nl
%aul,nul
%	[move15]

%nl*,c
%nul*,c
%	[move14a]

%nl*,al
%nl*,aul
%nul*,al
%nul*,aul
%	[move16a]

%el*,nl
%el*,nul
%eul*,nl
%eul*,nul
%	[move16]

%nl*,nl
%nl*,nul
%nul*,nl
%nul*,nul
%	[move17]

/* =^ */
ci79:
%al,nl
%al,nul
%aul,nl
%aul,nul
%	[move15]

%el*,nl
%el*,nul
%eul*,nl
%eul*,nul
%	[move16]

%nl*,nl
%nl*,nul
%nul*,nl
%nul*,nul
	FS*
	S
	I	R,*(sp)
	mov	(sp)+,R
	I	R+,2(R)

/* =+ */
ci70:
%n*,z
%a,z
%ab,1
%aub,1
%a,1
	I'B1	A1

%aw,aw
%	[move3]

%aw,nw*
%	[move4]

%aw,n
%	[move5]

%n*,1
%nub*,1
%	[move2]

%ew*,nw*
%	[move9]

%a,ew*
	S*
	movB1	A1',R1
	I	#2(R),R1
	movB1	R1,A1''

%a,n
	S
	movB1	A1',R1
	I	R,R1
	movB1	R1,A1''

%aub,n
	S
	clr	R1
	bisB1	A1',R1
	I	R,R1
	movB1	R1,A1''

%ew*,n
%	[move10]

%nw*,n
%	[move12]

%n*,n
	SS
	F*
	movB1	#1(R),R1
	I	(sp)+,R1
	movB1	R1,#1(R)

%nub*,n
	SS
	F*
	clr	R1
	bisB1	#1(R),R1
	I	(sp)+,R1
	movB1	R1,#1(R)

%al,c
%al,au
%aul,au
%aul,c
%	[move13a]

%al,al
%al,aul
%aul,al
%aul,aul
%	[move13]

%al,nl*
%al,nul*
%aul,nl*
%aul,nul*
%	[move14]

%al,nl
%al,nul
%aul,nl
%aul,nul
%	[move15]

%nl*,c
%nl*,au
%nul*,c
%nul*,au
%	[move14a]

%nl*,al
%nl*,aul
%nul*,al
%nul*,aul
%	[move16a]

%el*,nl
%el*,nul
%eul*,nl
%eul*,nul
%	[move16]

%nl*,nl
%nl*,nul
%nul*,nl
%nul*,nul
%	[move17]

/* =>> (all harder cases handled by =<< -) */
ci75:
%a,1
	asrB1	A1

%aub,1
	clc
	rorB1	A1

%n*,1
	F*
	asrB1	#1(R)

%nub*,1
	F*
	clc
	rorB1	#1(R)

/* =<< */
ci76:
%a,1
%aub,1
	aslB1	A1

%n*,1
%nub*,1
	F*
	aslB1	#1(R)

%r,aw
	ash	A2,A1

%r,nw*
	S*
	ash	#2(R),A1

%r,n
	S
	ash	R,A1

/* =<< for longs */
cr92:
%al,aw
%aul,aw
	F
	ashc	A2,R
	mov	R,A1
	mov	R+,A1+

%al,n
%aul,n
	SS
	F
	ashc	(sp)+,R
	mov	R,A1
	mov	R+,A1+

%nl*,n
%nul*,n
	FS*
	SS
	mov	2(sp),R
	mov	2(R),R+
	mov	(R),R
	ashc	(sp)+,R
	mov	R,*(sp)
	add	$2,(sp)
	mov	R+,*(sp)+

/* field = ... */
ci16:
%a,a
	bicB1	Z,A1'
	bisB1	A2,A1''

%a,n
	S
	bicB1	Z,A1'
	bisB1	R,A1''

%n*,a
	F*
	bicB1	Z,#1(R)
	bisB1	A2,#1(R)

%[fas1:]
%e*,n
	S
	F1*
	bicB1	Z,#1(R1)
	bisB1	R,#1(R1)

%n*,e
	F*
	S1
	bicB1	Z,#1(R)
	bisB1	R1,#1(R)

%n*,n
	SS
	F*
	bicB1	Z,#1(R)
	bisB1	(sp)+,#1(R)

%{
/*
 * c code tables-- set condition codes
 */

struct table cctab[] = {
	{106,cc60},
	{28,rest},
	{55,rest},
	{34,rest},
	{35,rest},
	{36,rest},
	{37,rest},
	{40,rest},
	{41,rest},
	{43,rest},
	{81,cc81	/* & as in "if ((a&b)==0)" */},
	{48,rest},
	{60,cc60},
	{61,cc60},
	{62,cc60},
	{63,cc60},
	{64,cc60},
	{65,cc60},
	{66,cc60},
	{67,cc60},
	{68,cc60},
	{69,cc60},
	{72,rest},
	{73,rest},
	{79,rest},
	{0}
};
%}

/* relationals */
cc60:
%a,z
%ad,zf
%aub,z
%	[move1]

%af,z
	movof	A1,R

%n*,z
%nd*,zf
%nub*,z
%	[move2]

%nf*,z
	F*
	movof	#1(R),R

%n,z
%nf,zf
	FC

%aw,aw
%ab,ab
%aub,a
%aub,aub
%	[move3]

%nw*,aw
%nb*,ab
%nub*,aub
%	[move6]

%n,aw
%nf,ad
%	[add1]

%nw*,ew*
%nb*,eb*
%nub*,eub*
%	[move7]

%nw*,e
%	[move8]

%n,ew*
%nf,ed*
%	[add2]

%n,e
%nf,ef
%	[add3]

%nw*,nw*
%nb*,nb*
%nub*,nub*
%	[move11]

%nw*,n
%	[move12]

%n,n
%nf,nf
%	[add5]

%al,z
%aul,z
	tst	A1
	X0
	tst	A1+
	X1

%al,c
%al,au
%aul,c
%aul,au
	tst	A1
	X0
	cmp	A1+,A2
	X1

%[lcmp1:]
%al,al
%al,aul
%aul,al
%aul,aul
	I	A1,A2
	X0
	I	A1+,A2+
	X1

%nl*,z
%nul*,z
	F*
	tst	#1(R)
	X0
	tst	#1+2(R)
	X1

%nl*,c
%nul*,c
%nl*,au
%nul*,au
	F*
	tst	#1(R)
	X0
	cmp	#1+2(R),A2
	X1

%[lcmp2:]
%nl*,al
%nl*,aul
%nul*,al
%nl*,aul
	F*
	I	#1(R),A2
	X0
	I	#1+2(R),A2+
	X1

%nl,z
%nul,z
	F
	tst	R
	X0
	tst	R+
	X1

%nl,c
%nul,c
%nl,au
%nul,au
	F
	tst	R
	X0
	cmp	R+,A2
	X1

%[lcmp3:]
%nl,al
%nl,aul
%nul,al
%nul,aul
	F
	I	R,A2
	X0
	I	R+,A2+
	X1

%[lcmp4:]
%nl*,el*
%nl*,eul*
%nul*,el*
%nul*,eul*
	F*
	S1*
	I	#1(R),#2(R1)
	X0
	I	#1+2(R),#2+2(R1)
	X1

%[lcmp5:]
%nl,el*
%nl,eul*
%nul,el*
%nul,eul*
	F
	S1*
	I	R,#2(R1)
	X0
	I	R+,#2+2(R1)
	X1

%[lcmp6:]
%nl,nl
%nl,nul
%nul,nl
%nul,nul
	FS
	S
	mov	R,-(sp)
	mov	4(sp),R
	mov	(sp)+,2(sp)
	I	(sp)+,(sp)+
	X0
	I	R,R+
	X1

/* & as in "if ((a&b) ==0)" */
cc81:
%a,a
%a,ab
%a,aub
%ab,a
%ab,ab
%ab,aub
%aub,a
%aub,ab
%aub,aub
%	[move3]

/*
   special case. apparently "u_char b; [u_]char a; if (b & a)..." was
   too complicated.  the resulting code was horrid.  this cuts the
   waste by 33%
*/

%a,e
%aub,e
	S
	IBE	R,A1

%n*,a
%nu*,a
%nub*,a
%	[move6]

%n,a
%	[add1]

%n,e
%	[add3]

%n,n
%	[add5]

%al,c
%aul,c
%al,au
%aul,au
	bit	A2,A1+
	X1

%nl*,c
%nul*,c
%nl*,au
%nul*,au
	F*
	bit	A2,#2+2(R)
	X1

%al,al
%al,aul
%aul,al
%aul,aul
%	[lcmp1]

%nl*,al
%nl*,aul
%nul*,al
%nul*,aul
%	[lcmp2]

%nl,al
%nl,aul
%nul,al
%nul,aul
%	[lcmp3]

%nl*,el*
%nl*,eul*
%nul*,el*
%nul*,eul*
%	[lcmp4]

%nl,el*
%nl,eul*
%nul,el*
%nul,eul*
%	[lcmp5]

%nl,nl
%nl,nul
%nul,nl
%nul,nul
%	[lcmp6]

%nl,c
%nul,c
%nl,au
%nul,au
	F
	bit	A2,R+
	X1

/* set codes right */
rest:
%n,n
%nf,nf
	H

%{
/*
 * c code tables-- expression to -(sp)
 */

struct table sptab[] = {
	{106,cs106},
	{40,cs40},
	{41,cs40},
	{55,cs40},
	{48,cs40},
	{58,cs58},
	{56,cs56},
	{0}
};
%}

/* name */
cs106:
%z,n
%zf,n
	clrB1	-(sp)

%aw,n
	mov	A1,-(sp)

%aub,n
	clr	-(sp)
	bisb	A1,(sp)

%nw*,n
	F*
	mov	#1(R),-(sp)

%al,n
%aul,n
	mov	A1+,-(sp)
	mov	A1,-(sp)

/* +, -, |, &~ */
cs40:
%a,1
	FS
	I'	(sp)

%a,aw
	FS
	I	A2,(sp)

%a,nw*
	FS
	S*
	I	#2(R),(sp)

%a,n
	FS
	S
	I	R,(sp)

/* integer to long */
cs58:
%nu,n
	FS
	clr	-(sp)

%aw,n
	mov	A1,-(sp)
	sxt	-(sp)

/* float to long */
cs56:
%nf,n
	F
	setl
	movfi	R,-(sp)
	seti

/* setup for structure assign */
ci116:
%n,e
	F!
	S1!

%n,n
	SS
	F!
	mov	(sp)+,r1

/* end of table */
