misc/efp.gp (2/2)
1 2
\\----------------------------------------------------------------------------------------
make_fdsqrt()={
  my(y);
  make_fop1to1("fdsqrt",
               "fdsqrt",
               -1,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_ONE_MINUS,
                      DATA_ONE_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\dsqrt(-Inf)=NaN,OE
                                x==-Rei,-Rei,  \\dsqrt(-0)=-0
                                x==Rei,Rei,  \\dsqrt(+0)=+0
                                x==Inf,Inf,  \\dsqrt(+Inf)=+Inf
                                NaN),
                             if(x<0,fpsr=bitor(fpsr,OE);NaN,  \\dsqrt(-x)=NaN,OE
                                y=dbl(sqrt(x),rm);
                                if(y^2!=x,fpsr=bitor(fpsr,X2));
                                y)))
  }


\\----------------------------------------------------------------------------------------
\\  FDSUB.X FPm,FPn
\\----------------------------------------------------------------------------------------
fdsub_func(x,y,rp,rm)={
  my(z);
  if(x==0,x=Rei);
  if(y==0,y=Rei);
  if((x==NaN)||(y==NaN),NaN,
     (x==Inf)&&(y==Inf),fpsr=bitor(fpsr,OE);NaN,  \\(+Inf)-(+Inf)=NaN,OE
     (x==-Inf)&&(y==-Inf),fpsr=bitor(fpsr,OE);NaN,  \\(-Inf)-(-Inf)=NaN,OE
     (x==Rei)&&(y==-Rei),Rei,  \\(+0)-(-0)=+0
     (x==-Rei)&&(y==Rei),-Rei,  \\(-0)-(+0)=-0
     (x==Rei)&&(y==Rei),if(rm==RM,-Rei,Rei),  \\(+0)-(+0)=±0
     (x==-Rei)&&(y==-Rei),if(rm==RM,-Rei,Rei),  \\(-0)-(-0)=±0
     (y==Inf)||(y==-Inf),-y,  \\(±x)-(±Inf)=∓Inf
     (x==Inf)||(x==-Inf),x,  \\(±Inf)-(±y)=±Inf
     (y==Rei)||(y==-Rei),dbl(x,rm),  \\(±x)-(±0)=(±x)
     (x==Rei)||(x==-Rei),dbl(-y,rm),  \\(±0)-(±y)=∓y
     z=x-y;
     if(z==0,
        if(rm==RM,-Rei,Rei),
        dbl(z,rm)))
  }
make_fdsub()={
  make_fop2to1("fdsub",
               "fdsub",
               -1,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               fdsub_func)
  }


\\----------------------------------------------------------------------------------------
\\  FETOX.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fetox()={
  my(y);
  make_fop1to1("fetox",
               "fetox",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,Rei,  \\etox(-Inf)=+0
                                x==-Rei,1,  \\etox(-0)=1
                                x==Rei,1,  \\etox(+0)=1
                                x==Inf,Inf,  \\etox(+Inf)=+Inf
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             if(x<=-65536,fpsr=bitor(fpsr,UF);xxx(Rei,rp,rm),  \\etox(-big)=+0,UF
                                65536<x,fpsr=bitor(fpsr,OF);xxx(Inf,rp,rm),  \\etox(+big)=+Inf,OF
                                xxx(exp(x),rp,rm))))
  }


\\----------------------------------------------------------------------------------------
\\  FETOXM1.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fetoxm1()={
  my(y);
  make_fop1to1("fetoxm1",
               "fetoxm1",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,-1,  \\etoxm1(-Inf)=-1
                                x==-Rei,-Rei,  \\etoxm1(-0)=-0
                                x==Rei,Rei,  \\etoxm1(+0)=+0
                                x==Inf,Inf,  \\etoxm1(+Inf)=+Inf
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             if(x<=-256,if((rm==RZ)||(rm==RP),nextup(-1,rp),-1),  \\etoxm1(-big)=-1
                                65536<=x,fpsr=bitor(fpsr,OF);xxx(Inf,rp,rm),  \\etoxm1(+big)=+INf,OF
                                y=roundxxx(expm1(x),rp,rm);
                                y=originUpperUpper(y,x,rp,rm);
                                y=xxx(y,rp,rm);
                                correctUnderflow(y,rp))))
  }


\\----------------------------------------------------------------------------------------
\\  FGETEXP.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fgetexp()={
  make_fop1to1("fgetexp",
               "fgetexp",
               -1,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\getexp(-Inf)=NaN,OE
                                x==-Rei,-Rei,  \\getexp(-0)=-0
                                x==Rei,Rei,  \\getexp(+0)=+0
                                x==Inf,fpsr=bitor(fpsr,OE);NaN,  \\getexp(+Inf)=NaN,OE
                                NaN),
                             exd(floor(log2(abs(x))),RN)))
  }


\\----------------------------------------------------------------------------------------
\\  FGETMAN.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fgetman()={
  make_fop1to1("fgetman",
               "fgetman",
               -1,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\getman(-Inf)=NaN,OE
                                x==-Rei,-Rei,  \\getman(-0)=-0
                                x==Rei,Rei,  \\getman(+0)=+0
                                x==Inf,fpsr=bitor(fpsr,OE);NaN,  \\getman(+Inf)=NaN,OE
                                NaN),
                             exd(2^-floor(log2(abs(x)))*x,RN)))
  }


\\----------------------------------------------------------------------------------------
\\  FINT.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fint()={
  my(y);
  make_fop1to1("fint",
               "fint",
               -1,
               MC68881+MC68882+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,-Inf,  \\int(-Inf)=-Inf
                                x==-Rei,-Rei,  \\int(-0)=-0
                                x==Rei,Rei,  \\int(+0)=+0
                                x==Inf,Inf,  \\int(+Inf)=+Inf
                                NaN),
                             y=if(rm==RN,rint(x),
                                  rm==RZ,trunc(x),
                                  rm==RM,floor(x),
                                  rm==RP,ceil(x),
                                  error());
                             if(y!=x,fpsr=bitor(fpsr,X2));
                             if(y==0,y=if(x<0,-Rei,Rei));
                             \\FINTはsingleとdoubleの丸め処理を行わない
                             y))
  }


\\----------------------------------------------------------------------------------------
\\  FINTRZ.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fintrz()={
  my(y);
  make_fop1to1("fintrz",
               "fintrz",
               -1,
               MC68881+MC68882+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,-Inf,  \\intrz(-Inf)=-Inf
                                x==-Rei,-Rei,  \\intrz(-0)=-0
                                x==Rei,Rei,  \\intrz(+0)=+0
                                x==Inf,Inf,  \\intrz(+Inf)=+Inf
                                NaN),
                             y=trunc(x);
                             if(y!=x,fpsr=bitor(fpsr,X2));
                             if(y==0,y=if(x<0,-Rei,Rei));
                             \\FINTRZはsingleとdoubleの丸め処理を行わない
                             y))
  }


\\----------------------------------------------------------------------------------------
\\  FLOG10.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_flog10()={
  make_fop1to1("flog10",
               "flog10",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_ONE_MINUS,
                      DATA_ONE_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\log10(-Inf)=NaN,OE
                                x==-Rei,fpsr=bitor(fpsr,DZ);-Inf,  \\log10(-0)=-Inf,DZ
                                x==Rei,fpsr=bitor(fpsr,DZ);-Inf,  \\log10(+0)=-Inf,DZ
                                x==Inf,Inf,  \\log10(+Inf)=+Inf
                                NaN),
                             x<0,fpsr=bitor(fpsr,OE);NaN,  \\log10(x<0)=NaN,OE
                             x==1,if(rm==RM,-Rei,Rei),  \\log10(1)=±0
                             fpsr=bitor(fpsr,X2);
                             xxx(log10(x),rp,rm)))
  }


\\----------------------------------------------------------------------------------------
\\  FLOG2.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_flog2()={
  make_fop1to1("flog2",
               "flog2",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_ONE_MINUS,
                      DATA_ONE_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\log2(-Inf)=NaN,OE
                                x==-Rei,fpsr=bitor(fpsr,DZ);-Inf,  \\log2(-0)=-Inf,DZ
                                x==Rei,fpsr=bitor(fpsr,DZ);-Inf,  \\log2(+0)=-Inf,DZ
                                x==Inf,Inf,  \\log2(+Inf)=+Inf
                                NaN),
                             x<0,fpsr=bitor(fpsr,OE);NaN,  \\log2(x<0)=NaN,OE
                             x==1,if(rm==RM,-Rei,Rei),  \\log2(1)=±0
                             fpsr=bitor(fpsr,X2);
                             xxx(log2(x),rp,rm)))
  }


\\----------------------------------------------------------------------------------------
\\  FLOGN.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_flogn()={
  make_fop1to1("flogn",
               "flogn",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_ONE_MINUS,
                      DATA_ONE_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\logn(-Inf)=NaN,OE
                                x==-Rei,fpsr=bitor(fpsr,DZ);-Inf,  \\logn(-0)=-Inf,DZ
                                x==Rei,fpsr=bitor(fpsr,DZ);-Inf,  \\logn(+0)=-Inf,DZ
                                x==Inf,Inf,  \\logn(+Inf)=+Inf
                                NaN),
                             x<0,fpsr=bitor(fpsr,OE);NaN,  \\logn(x<0)=NaN,OE
                             x==1,if(rm==RM,-Rei,Rei),  \\logn(1)=±0
                             fpsr=bitor(fpsr,X2);
                             xxx(log(x),rp,rm)))
  }


\\----------------------------------------------------------------------------------------
\\  FLOGNP1.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_flognp1()={
  my(y);
  make_fop1to1("flognp1",
               "flognp1",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_ONE_MINUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\lognp1(-Inf)=NaN,OE
                                x==-Rei,-Rei,  \\lognp1(-0)=-0
                                x==Rei,Rei,  \\lognp1(+0)=+0
                                x==Inf,Inf,  \\lognp1(+Inf)=+Inf
                                NaN),
                             x<-1,fpsr=bitor(fpsr,OE);NaN,  \\lognp1(x<-1)=NaN,OE
                             x==-1,fpsr=bitor(fpsr,DZ);-Inf,  \\lognp1(-1)=-Inf,DZ
                             fpsr=bitor(fpsr,X2);
                             y=roundxxx(log(1+x),rp,rm);
                             y=originLowerLower(y,x,rp,rm);
                             y=xxx(y,rp,rm);
                             correctUnderflow(y,rp)))
  }


\\----------------------------------------------------------------------------------------
\\  FMOD.X FPm,FPn
\\----------------------------------------------------------------------------------------
fmod_func(x,y,rp,rm)={
  my(q,z);
  fpsr=bitand(fpsr,0xFF00FFFF);  \\quotient byteをクリアする
  if((x==NaN)||(y==NaN),NaN,
     (x==Inf)||(x==-Inf),fpsr=bitor(fpsr,OE);NaN,  \\(±Inf)%(±y)=NaN,OE
     (y==Rei)||(y==-Rei),fpsr=bitor(fpsr,OE);NaN,  \\(±x)%(±0)=NaN,OE
     fpsr=bitor(fpsr,bitxor(isminus(x),isminus(y))<<23);  \\商の符号
     if((x==Rei)||(x==-Rei),x,  \\(±0)%(±y)=±0,商は±0
        (y==Inf)||(y==-Inf),xxx(x,rp,rm),  \\(±x)%(±Inf)=±x,商は±0。xが非正規化数のときUFをセットする
        q=trunc(x/y);
        fpsr=bitor(fpsr,bitand(abs(q),127)<<16);  \\商の絶対値の下位7bit
        z=xxx(x-q*y,rp,rm);
        if((z==Rei)||(z==-Rei),z=sign(x)*Rei);  \\余りが0のときは0にxの符号を付ける
        z))
  }
make_fmod()={
  make_fop2to1("fmod",
               "fmod",
               -1,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               fmod_func)
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.B FPn,Dr
\\  FMOVE.B FPn,<mem>
\\----------------------------------------------------------------------------------------
make_fmovebregto()={
  my(a,x,u,rp,rm,sr);
  print("making fmovebregto");
  a=append(DATA_SPECIAL,
           DATA_FLOAT,
           DATA_BASIC,
           DATA_ROUND);
  a=vector(#a,n,exd(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.B FPn,Dr
;	FMOVE.B FPn,<mem>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovebregto_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.B FPN,<EA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.B FPn,<ea>',13,10
;------------------------------------------------
;	d1	actual result
;	d3	fill=$00000000,$FFFFFFFF
;	d4	actual status
;	d6	fpcr=(XRN..DRP)<<4
;	d7	0=failed,1=successful
;	a0	expected result,expected status,...
;	a1	expected result
;	a4	expected status
;	a5	source handle,...
;	fp5	source
;------------------------------------------------
	lea.l	push_decompressed,a3
;decompress data
	move.l	a3,-(sp)
	pea.l	fmovebregto_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a3,a5			;source handle,...
@@:
	add.l	d0,(a3)+		;source handle
	tst.l	(a3)
	bpl	@b
	addq.l	#4,a3			;-1
	movea.l	a3,a0			;expected result,expected status,...
;
55:
	move.l	#",XRN<<4,",d6		;fpcr=(XRN..DRP)<<4
66:
;FPn,Dr=fill
	moveq.l	#$00000000,d3		;fill=$00000000,$FFFFFFFF
33:
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	d3,d1			;fill
					;source
	fmove.b	fp5,d1			;EXECUTE
					;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.B FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',Dr='
	puthex8	d3			;fill
	putmsg	' @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result,expected status,...
;
	not.l	d3			;fill
	bne	33b
;FPn,<mem>=fill
	moveq.l	#$00000000,d3		;fill=$00000000,$FFFFFFFF
33:
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	d3,-(sp)		;fill
					;source
	fmove.b	fp5,(sp)		;EXECUTE
	move.l	(sp)+,d1		;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.B FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',<mem>='
	puthex8	d3			;fill
	putmsg	' @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result,expected status,...
;
	not.l	d3			;fill
	bne	33b
;
	add.w	#1<<4,d6		;rprm++
	cmp.w	#",DRP<<4,",d6		;fpcr=(XRN..DRP)<<4
	bls	66b
;
	addq.l	#4,a5			;source handle
	tst.l	(a5)			;source handle
	bpl	55b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovebregto_data_compressed::
");
  push_start();
  for(i=1,#a,
      x=a[i];  \\ソース
      push_indirect(12,numtoexd(x,RN)));
  push(4,-1);
  for(i=1,#a,
      x=a[i];  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          u=numtobyte(x,rm);  \\byteに変換する
          fpsr_update_aer();
          sr=fpsr;
          push(4,0x00000000+u);
          push(4,sr);
          push(4,0xFFFFFF00+u);
          push(4,sr);
          push(4,(u<<24)+0x000000);
          push(4,sr);
          push(4,(u<<24)+0xFFFFFF);
          push(4,sr)));
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.B Dr,FPn
\\  FMOVE.B <mem>,FPn
\\----------------------------------------------------------------------------------------
make_fmovebtoreg()={
  my(a,u,y,rp,rm,sr);
  print("making fmovebtoreg");
  a=DATA_BYTE;
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.B Dr,FPn
;	FMOVE.B <mem>,FPn
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovebtoreg_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.B <EA>,FPN'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.B <ea>,FPn',13,10
;------------------------------------------------
;	d1	fpcr=(XRN..DRP)<<4
;	d2	source
;	d3	0=failed,1=successful
;	d5	expected status
;	d7	actual status
;	a2	source,...
;	a4	expected result handle,expected status,...
;	fp5	expected result
;	fp7	actual result
;------------------------------------------------
	lea.l	push_decompressed,a0
;decompress data
	move.l	a0,-(sp)
	pea.l	fmovebtoreg_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a0,a2			;source,...
@@:
	addq.l	#4,a0			;source
	tst.l	(a0)
	bne	@b
	addq.l	#4,a0			;0
	movea.l	a0,a4			;expected result handle,expected status,...
@@:
	add.l	d0,(a0)+		;expected result handle
	addq.l	#4,a0			;expected status
	tst.l	(a0)
	bpl	@b
;	addq.l	#4,a0			;-1
;
22:
	move.l	#",XRN<<4,",d1		;fpcr=(XRN..DRP)<<4
11:
;Dr,FPn
	fmove.l	#0,fpcr
	moveq.l	#0,d2
	move.b	(a2),d2			;source
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
					;source
	fmove.b	d2,fp7			;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.B Dr='
	puthex2	d2			;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
;<mem>,FPn
	fmove.l	#0,fpcr
	moveq.l	#0,d2
	move.b	(a2),d2			;source
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.b	d2,-(sp)		;source
	fmove.b	(sp)+,fp7		;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.B <mem>='
	puthex2	d2			;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a4			;expected result
;
	add.w	#1<<4,d1		;rprm++
	cmp.w	#",DRP<<4,",d1		;fpcr=(XRN..DRP)<<4
	bls	11b
;
	addq.l	#4,a2			;source
	tst.l	(a2)			;source
	bne	22b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovebtoreg_data_compressed::
");
  push_start();
  for(i=1,#a,
      u=a[i];  \\ソース
      push(1,u);
      push(3,0));
  push(4,0);
  for(i=1,#a,
      u=a[i];  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          y=bytetonum(u);
          y=roundxxx(y,rp,rm);
          fpsr_update_ccr(y);
          fpsr_update_aer();
          sr=fpsr;
          push_indirect(12,numtoexd(y,RN));
          push(4,sr)));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.D FPn,<mem>
\\----------------------------------------------------------------------------------------
make_fmovedregto()={
  my(a,x,u,rp,rm,sr);
  print("making fmovedregto");
  a=append(DATA_SPECIAL,
           DATA_FLOAT,
           DATA_BASIC,
           DATA_ROUND);
  a=vector(#a,n,exd(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.D FPn,<mem>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovedregto_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.D FPN,<EA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.D FPn,<ea>',13,10
;------------------------------------------------
;	d1-d2	actual result
;	d4	actual status
;	d6	fpcr=(XRN..DRP)<<4
;	d7	0=failed,1=successful
;	a0	expected result handle,expected status,...
;	a1-a2	expected result
;	a4	expected status
;	a5	source handle,...
;	fp5	source
;------------------------------------------------
	lea.l	push_decompressed,a3
;decompress data
	move.l	a3,-(sp)
	pea.l	fmovedregto_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a3,a5			;source handle,...
@@:
	add.l	d0,(a3)+		;source handle
	tst.l	(a3)
	bpl	@b
	addq.l	#4,a3			;-1
	movea.l	a3,a0			;expected result handle,expected status,...
@@:
	add.l	d0,(a3)+		;expected result handle
	addq.l	#4,a3			;expected status
	tst.l	(a3)
	bpl	@b
;	addq.l	#4,a3			;-1
;
55:
	move.l	#",XRN<<4,",d6		;fpcr=(XRN..DRP)<<4
66:
;FPn,<mem>
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	#-1,-(sp)		;fill=-1
	move.l	#-1,-(sp)
					;source
	fmove.d	fp5,(sp)		;EXECUTE
	movem.l	(sp)+,d1-d2		;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movem.l	([a0]),a1-a2		;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1-d2/d4/a1-a2/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_double
	lea.l	24(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.D FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',<mem> @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1-d2/d4/a1-a2/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_double
	lea.l	28(sp),sp
@@:
;
	addq.l	#8,a0			;expected
;
	add.w	#1<<4,d6		;rprm++
	cmp.w	#",DRP<<4,",d6		;fpcr=(XRN..DRP)<<4
	bls	66b
;
	addq.l	#4,a5			;source handle
	tst.l	(a5)			;source handle
	bpl	55b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovedregto_data_compressed::
");
  push_start();
  for(i=1,#a,
      x=a[i];  \\ソース
      push_indirect(12,numtoexd(x,RN)));
  push(4,-1);
  for(i=1,#a,
      x=a[i];  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          u=numtodbl(x,if(type(x)=="t_POL",RN,rm));  \\doubleに変換する
          fpsr_update_aer();
          sr=fpsr;
          push_indirect(8,u);
          push(4,sr)));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.D <mem>,FPn
\\----------------------------------------------------------------------------------------
make_fmovedtoreg()={
  my(a,u,y,rp,rm,sr);
  print("making fmovedtoreg");
  a=append(DATA_SPECIAL,
           DATA_DOUBLE,
           DATA_BASIC,
           DATA_ROUND);
  a=vector(#a,n,dbl(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.D <mem>,FPn
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovedtoreg_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.D <EA>,FPN'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.D <ea>,FPn',13,10
;------------------------------------------------
;	d1	fpcr=(XRN..DRP)<<4
;	d3	0=failed,1=successful
;	d5	expected status
;	d7	actual status
;	a2	source handle,...
;	a4	expected result handle,expected status,...
;	fp5	expected result
;	fp7	actual result
;------------------------------------------------
	lea.l	push_decompressed,a0
;decompress data
	move.l	a0,-(sp)
	pea.l	fmovedtoreg_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a0,a2			;source handle,...
@@:
	add.l	d0,(a0)+		;source handle
	tst.l	(a0)
	bpl	@b
	addq.l	#4,a0			;-1
	movea.l	a0,a4			;expected result handle,expected status,...
@@:
	add.l	d0,(a0)+		;expected result handle
	addq.l	#4,a0			;expected status
	tst.l	(a0)
	bpl	@b
;	addq.l	#4,a0			;-1
;
22:
	move.l	#",XRN<<4,",d1		;fpcr=(XRN..DRP)<<4
11:
;<mem>,FPn
	fmove.l	#0,fpcr
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
					;source
	fmove.d	([a2]),fp7		;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.D <mem>='
	puthex16	([a2]),(4,[a2])	;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a4			;expected result
;
	add.w	#1<<4,d1		;rprm++
	cmp.w	#",DRP<<4,",d1		;fpcr=(XRN..DRP)<<4
	bls	11b
;
	addq.l	#4,a2			;source handle,...
	tst.l	(a2)			;source handle,...
	bpl	22b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovedtoreg_data_compressed::
");
  push_start();
  for(i=1,#a,
      u=numtodbl(a[i],RN);  \\ソース
      push_indirect(8,u));
  push(4,-1);
  for(i=1,#a,
      u=numtodbl(a[i],RN);  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          y=dbltonum(u);
          if((rp==DBL)&&
             ((bitand(u,0x7FF0000000000000)==0)&&
              (bitand(u,0x000FFFFFFFFFFFFF)!=0)),
             fpsr=bitor(fpsr,UF));  \\丸め桁数がdoubleで非正規化数のときUFをセットする
          if(rp==SGL,
             if(type(y)!="t_POL",
                y=xxx(y,rp,rm)),
             y=roundxxx(y,rp,rm));
          fpsr_update_ccr(y);
          fpsr_update_aer();
          sr=fpsr;
          push_indirect(12,numtoexd(y,RN));
          push(4,sr)));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.L FPn,Dr
\\  FMOVE.L FPn,<mem>
\\----------------------------------------------------------------------------------------
make_fmovelregto()={
  my(a,x,u,rp,rm,sr);
  print("making fmovelregto");
  a=append(DATA_SPECIAL,
           DATA_FLOAT,
           DATA_BASIC,
           DATA_ROUND);
  a=vector(#a,n,exd(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.L FPn,Dr
;	FMOVE.L FPn,<mem>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovelregto_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.L FPN,<EA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.L FPn,<ea>',13,10
;------------------------------------------------
;	d1	actual result
;	d4	actual status
;	d6	fpcr=(XRN..DRP)<<4
;	d7	0=failed,1=successful
;	a0	expected result,expected status,...
;	a1	expected result
;	a4	expected status
;	a5	source handle,...
;	fp5	source
;------------------------------------------------
	lea.l	push_decompressed,a3
;decompress data
	move.l	a3,-(sp)
	pea.l	fmovelregto_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a3,a5			;source handle,...
@@:
	add.l	d0,(a3)+		;source handle
	tst.l	(a3)
	bpl	@b
	addq.l	#4,a3			;-1
	movea.l	a3,a0			;expected result,expected status,...
;
55:
	move.l	#",XRN<<4,",d6		;fpcr=(XRN..DRP)<<4
66:
;FPn,Dr
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	#-1,d1			;fill=-1
					;source
	fmove.l	fp5,d1			;EXECUTE
					;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.L FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',Dr @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result,expected status,...
;FPn,<mem>
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	#-1,-(sp)		;fill=-1
					;source
	fmove.l	fp5,(sp)		;EXECUTE
	move.l	(sp)+,d1		;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.L FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',<mem> @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result,expected status,...
;
	add.w	#1<<4,d6		;rprm++
	cmp.w	#",DRP<<4,",d6		;fpcr=(XRN..DRP)<<4
	bls	66b
;
	addq.l	#4,a5			;source handle
	tst.l	(a5)			;source handle
	bpl	55b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovelregto_data_compressed::
");
  push_start();
  for(i=1,#a,
      x=a[i];  \\ソース
      push_indirect(12,numtoexd(x,RN)));
  push(4,-1);
  for(i=1,#a,
      x=a[i];  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          u=numtolong(x,rm);  \\longに変換する
          fpsr_update_aer();
          sr=fpsr;
          push(4,u);
          push(4,sr);
          push(4,u);
          push(4,sr)));
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.L Dr,FPn
\\  FMOVE.L <mem>,FPn
\\----------------------------------------------------------------------------------------
make_fmoveltoreg()={
  my(a,u,y,rp,rm,sr);
  print("making fmoveltoreg");
  a=DATA_LONG;
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.L Dr,FPn
;	FMOVE.L <mem>,FPn
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmoveltoreg_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.L <EA>,FPN'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.L <ea>,FPn',13,10
;------------------------------------------------
;	d1	fpcr=(XRN..DRP)<<4
;	d2	source
;	d3	0=failed,1=successful
;	d5	expected status
;	d7	actual status
;	a2	source,...
;	a4	expected result handle,expected status,...
;	fp5	expected result
;	fp7	actual result
;------------------------------------------------
	lea.l	push_decompressed,a0
;decompress data
	move.l	a0,-(sp)
	pea.l	fmoveltoreg_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a0,a2			;source,...
@@:
	addq.l	#4,a0			;source
	tst.l	(a0)
	bne	@b
	addq.l	#4,a0			;0
	movea.l	a0,a4			;expected result handle,expected status,...
@@:
	add.l	d0,(a0)+		;expected result handle
	addq.l	#4,a0			;expected status
	tst.l	(a0)
	bpl	@b
;	addq.l	#4,a0			;-1
;
22:
	move.l	#",XRN<<4,",d1		;fpcr=(XRN..DRP)<<4
11:
;Dr,FPn
	fmove.l	#0,fpcr
	move.l	(a2),d2			;source
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
					;source
	fmove.l	d2,fp7			;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.L Dr='
	puthex8	d2			;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
;<mem>,FPn
	fmove.l	#0,fpcr
	move.l	(a2),d2			;source
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	d2,-(sp)		;source
	fmove.l	(sp)+,fp7		;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.L <mem>='
	puthex8	d2			;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a4			;expected result
;
	add.w	#1<<4,d1		;rprm++
	cmp.w	#",DRP<<4,",d1		;fpcr=(XRN..DRP)<<4
	bls	11b
;
	addq.l	#4,a2			;source
	tst.l	(a2)			;source
	bne	22b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmoveltoreg_data_compressed::
");
  push_start();
  for(i=1,#a,
      u=a[i];  \\ソース
      push(4,u));
  push(4,0);
  for(i=1,#a,
      u=a[i];  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          y=longtonum(u);
          y=roundxxx(y,rp,rm);
          fpsr_update_ccr(y);
          fpsr_update_aer();
          sr=fpsr;
          push_indirect(12,numtoexd(y,RN));
          push(4,sr)));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.P FPn,<mem>{#k}
\\  FMOVE.P FPn,<mem>{Dk}
\\----------------------------------------------------------------------------------------
make_fmovepregto()={
  my(name="fmovepregto",a,x,u,rp,rm,sr);
  print("making ",name);
  a=append(DATA_SPECIAL,
           DATA_FLOAT,
           DATA_BASIC,
           DATA_PACKED);
  a=vector(#a,n,exd(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.P FPn,<mem>{#k}
;	FMOVE.P FPn,<mem>{Dk}
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
",name,"_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+FPSP040+FPSP060,-(sp)
	peamsg	'FMOVE.P FPN,<EA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.P FPn,<ea>',13,10
;------------------------------------------------
;	d1-d3	actual result
;	d4	actual status
;	d5	0=failed,1=successful
;	d6	fpcr=(XRN..XRP)<<4
;	d7	k-factor=-18..18
;	a0	expected result handle,expected status,...
;	a1-a3	expected result
;	a4	expected status
;	a5	source handle,...
;	fp5	source
;------------------------------------------------
	lea.l	push_decompressed,a3
;decompress data
	move.l	a3,-(sp)
	pea.l	",name,"_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a3,a5			;source handle,...
@@:
	add.l	d0,(a3)+		;source handle
	tst.l	(a3)
	bpl	@b
	addq.l	#4,a3			;-1
	movea.l	a3,a0			;expected result handle,expected status,...
@@:
	add.l	d0,(a3)+		;expected result handle
	addq.l	#4,a3			;expected status
	tst.l	(a3)
	bpl	@b
;	addq.l	#4,a3			;-1
;
55:
	move.l	#",XRN<<4,",d6		;fpcr=(XRN..XRP)<<4
66:
	moveq.l	#-18,d7			;k-factor=-18..18
77:
;FPn,<mem>{#k}
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	#-1,-(sp)		;fill=-1
	move.l	#-1,-(sp)
	move.l	#-1,-(sp)
					;k-factor
					;execute
	jsr	(",name,"_execute+18*8,pc,d7.l*8)	;EXECUTE
	movem.l	(sp)+,d1-d3		;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movem.l	([a0]),a1-a3		;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_packed
	lea.l	32(sp),sp
	move.l	d0,d5			;0=failed,1=successful
;
	move.l	d5,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.P FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',<mem>{#'
	putlong	d7			;k-factor
	putmsg	'} @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d5,-(sp)		;0=failed,1=successful
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_packed
	lea.l	36(sp),sp
@@:
;
;FPn,<mem>{Dk}
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	#-1,-(sp)		;fill=-1
	move.l	#-1,-(sp)
	move.l	#-1,-(sp)
					;source
	fmove.p	fp5,(sp){d7}		;EXECUTE
	movem.l	(sp)+,d1-d3		;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movem.l	([a0]),a1-a3		;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_packed
	lea.l	32(sp),sp
	move.l	d0,d5			;0=failed,1=successful
;
	move.l	d5,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.P FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',<mem>{Dr='
	putlong	d7			;k-factor
	putmsg	'} @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d5,-(sp)		;0=failed,1=successful
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_packed
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a0			;expected result handle,expected status,...
;
	addq.l	#1,d7			;k-factor++
	cmp.l	#18,d7			;k-factor=-18..18
	ble	77b			;signed
;
	add.w	#1<<4,d6		;rprm++
	cmp.w	#",XRP<<4,",d6		;fpcr=(XRN..XRP)<<4
	bls	66b
;
	addq.l	#4,a5			;source handle,...
	tst.l	(a5)			;source handle,...
	bpl	55b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

",name,"_execute::
");
  for(k=-18,18,  \\k-factor
      asmln("	fmove.p	fp5,(4,sp){#",k,"}");
      asmln("	rts"));
  asm(
"	.cpu	68000

	.align	4
",name,"_data_compressed::
");
  push_start();
  for(i=1,#a,
      x=a[i];  \\ソース
      push_indirect(12,numtoexd(x,RN)));
  push(4,-1);
  for(i=1,#a,
      x=a[i];  \\ソース
      for(rprm=XRN,XRP,  \\(rp<<2)+rm。丸め桁数と丸めモード。extendedのみ
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          for(k=-18,18,  \\k-factor
              fpsr=0;
              u=numtopkd2(x,k,rm);  \\packedに変換する
              fpsr_update_aer();
              sr=fpsr;
              push_indirect(12,u);
              push(4,sr))));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.P <mem>,FPn
\\----------------------------------------------------------------------------------------
make_fmoveptoreg()={
  my(a,u,y,rp,rm,sr);
  print("making fmoveptoreg");
  a=append(DATA_SPECIAL,
           DATA_FLOAT,
           DATA_BASIC,
           DATA_ROUND,
           DATA_PACKED);
  a=vector(#a,n,pkd(a[n]));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.P <mem>,FPn
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmoveptoreg_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+FPSP040+FPSP060,-(sp)
	peamsg	'FMOVE.P <EA>,FPN'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.P <ea>,FPn',13,10
;------------------------------------------------
;	d1	fpcr=(XRN..DRP)<<4
;	d3	0=failed,1=successful
;	d5	expected status
;	d7	actual status
;	a2	source handle,...
;	a4	expected result handle,expected status,...
;	fp5	expected result
;	fp7	actual result
;------------------------------------------------
	lea.l	push_decompressed,a0
;decompress data
	move.l	a0,-(sp)
	pea.l	fmoveptoreg_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a0,a2			;source handle,...
@@:
	add.l	d0,(a0)+		;source handle
	tst.l	(a0)
	bpl	@b
	addq.l	#4,a0			;-1
	movea.l	a0,a4			;expected result handle,expected status,...
@@:
	add.l	d0,(a0)+		;expected result handle
	addq.l	#4,a0			;expected status
	tst.l	(a0)
	bpl	@b
;	addq.l	#4,a0			;-1
;
22:
	move.l	#",XRN<<4,",d1		;fpcr=(XRN..DRP)<<4
11:
;<mem>,FPn
	fmove.l	#0,fpcr
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
					;source
	fmove.p	([a2]),fp7		;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	d1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.P <mem>='
	puthex24	([a2]),(4,[a2]),(8,[a2])	;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a4			;expected result
;
	add.w	#1<<4,d1		;rprm++
	cmp.w	#",DRP<<4,",d1		;fpcr=(XRN..DRP)<<4
	bls	11b
;
	addq.l	#4,a2			;source handle,...
	tst.l	(a2)			;source handle,...
	bpl	22b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmoveptoreg_data_compressed::
");
  push_start();
  for(i=1,#a,
      u=numtopkd(a[i],17,RN);  \\ソース
      push_indirect(12,u));
  push(4,-1);
  for(i=1,#a,
      u=numtopkd(a[i],17,RN);  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          y=pkdtoxxx(u,rp,rm);
          fpsr_update_ccr(y);
          fpsr_update_aer();
          sr=fpsr;
          push_indirect(12,numtoexd(y,RN));
          push(4,sr)));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.S FPn,Dr
\\  FMOVE.S FPn,<mem>
\\----------------------------------------------------------------------------------------
make_fmovesregto()={
  my(a,x,u,rp,rm,sr);
  print("making fmovesregto");
  a=append(DATA_SPECIAL,
           DATA_FLOAT,
           DATA_BASIC,
           DATA_ROUND);
  a=vector(#a,n,exd(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.S FPn,Dr
;	FMOVE.S FPn,<mem>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovesregto_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.S FPN,<EA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.S FPn,<ea>',13,10
;------------------------------------------------
;	d1	actual result
;	d4	actual status
;	d6	fpcr=(XRN..DRP)<<4
;	d7	0=failed,1=successful
;	a0	expected result,expected status,...
;	a1	expected result
;	a4	expected status
;	a5	source handle,...
;	fp5	source
;------------------------------------------------
	lea.l	push_decompressed,a3
;decompress data
	move.l	a3,-(sp)
	pea.l	fmovesregto_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a3,a5			;source handle,...
@@:
	add.l	d0,(a3)+		;source handle
	tst.l	(a3)
	bpl	@b
	addq.l	#4,a3			;-1
	movea.l	a3,a0			;expected result,expected status,...
;
55:
	move.l	#",XRN<<4,",d6		;fpcr=(XRN..DRP)<<4
66:
;FPn,Dr
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	#-1,d1			;fill=-1
					;source
	fmove.s	fp5,d1			;EXECUTE
					;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.S FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',Dr @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
;FPn,<mem>
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	#-1,-(sp)		;fill=-1
					;source
	fmove.s	fp5,(sp)		;EXECUTE
	move.l	(sp)+,d1		;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.S FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',<mem> @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected
;
	add.w	#1<<4,d6		;rprm++
	cmp.w	#",DRP<<4,",d6		;fpcr=(XRN..DRP)<<4
	bls	66b
;
	addq.l	#4,a5			;source handle
	tst.l	(a5)			;source handle
	bpl	55b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovesregto_data_compressed::
");
  push_start();
  for(i=1,#a,
      x=a[i];  \\ソース
      push_indirect(12,numtoexd(x,RN)));
  push(4,-1);
  for(i=1,#a,
      x=a[i];  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          u=numtosgl(x,if(type(x)=="t_POL",RN,rm));  \\singleに変換する
          fpsr_update_aer();
          sr=fpsr;
          push(4,u);
          push(4,sr)));
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.S Dr,FPn
\\  FMOVE.S <mem>,FPn
\\----------------------------------------------------------------------------------------
make_fmovestoreg()={
  my(a,u,y,rp,rm,sr);
  print("making fmovestoreg");
  a=append(DATA_SPECIAL,
           DATA_SINGLE,
           DATA_BASIC,
           DATA_ROUND);
  a=vector(#a,n,sgl(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.S Dr,FPn
;	FMOVE.S <mem>,FPn
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovestoreg_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.S <EA>,FPN'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.S <ea>,FPn',13,10
;------------------------------------------------
;	d1	fpcr=(XRN..DRP)<<4
;	d2	source
;	d3	0=failed,1=successful
;	d5	expected status
;	d7	actual status
;	a2	source,...
;	a4	expected result handle,expected status,...
;	fp5	expected result
;	fp7	actual result
;------------------------------------------------
	lea.l	push_decompressed,a0
;decompress data
	move.l	a0,-(sp)
	pea.l	fmovestoreg_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a0,a2			;source,...
@@:
	addq.l	#4,a0			;source
	cmpi.l	#$FF800000,(a0)		;-Inf
	bne	@b
	addq.l	#4,a0			;0
	movea.l	a0,a4			;expected result handle,expected status,...
@@:
	add.l	d0,(a0)+		;expected result handle
	addq.l	#4,a0			;expected status
	tst.l	(a0)
	bpl	@b
;	addq.l	#4,a0			;-1
;
22:
	move.l	#",XRN<<4,",d1		;fpcr=(XRN..DRP)<<4
11:
;Dr,FPn
	fmove.l	#0,fpcr
	move.l	(a2),d2			;source
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
					;source
	fmove.s	d2,fp7			;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.S Dr='
	puthex8	d2			;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
;<mem>,FPn
	fmove.l	#0,fpcr
	move.l	(a2),d2			;source
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	d2,-(sp)		;source
	fmove.s	(sp)+,fp7		;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.S <mem>='
	puthex8	d2			;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a4			;expected result
;
	add.w	#1<<4,d1		;rprm++
	cmp.w	#",DRP<<4,",d1		;fpcr=(XRN..DRP)<<4
	bls	11b
;
	addq.l	#4,a2			;source,...
	cmpi.l	#$FF800000,(a2)		;source,.... -Inf
	bne	22b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovestoreg_data_compressed::
");
  push_start();
  for(i=1,#a,
      u=numtosgl(a[i],RN);  \\ソース
      push(4,u));
  push(4,0xFF800000);  \\-Inf。昇順にソートされているので途中に出てくる0を番兵にできない。先頭は-Infなので-Infを番兵にする
  for(i=1,#a,
      u=numtosgl(a[i],RN);  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          y=sgltonum(u);
          if((rp==SGL)&&
             ((bitand(u,0x7F800000)==0)&&
              (bitand(u,0x007FFFFF)!=0)),
             fpsr=bitor(fpsr,UF));  \\丸め桁数がsingleで非正規化数のときUFをセットする
          y=roundxxx(y,rp,rm);
          fpsr_update_ccr(y);
          fpsr_update_aer();
          sr=fpsr;
          push_indirect(12,numtoexd(y,RN));
          push(4,sr)));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.W FPn,Dr
\\  FMOVE.W FPn,<mem>
\\----------------------------------------------------------------------------------------
make_fmovewregto()={
  my(a,x,u,rp,rm,sr);
  print("making fmovewregto");
  a=append(DATA_SPECIAL,
           DATA_FLOAT,
           DATA_BASIC,
           DATA_ROUND);
  a=vector(#a,n,exd(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.W FPn,Dr
;	FMOVE.W FPn,<mem>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovewregto_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.W FPN,<EA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.W FPn,<ea>',13,10
;------------------------------------------------
;	d1	actual result
;	d3	fill=$00000000,$FFFFFFFF
;	d4	actual status
;	d6	fpcr=(XRN..DRP)<<4
;	d7	0=failed,1=successful
;	a0	expected result,expected status,...
;	a1	expected result
;	a4	expected status
;	a5	source handle,...
;	fp5	source
;------------------------------------------------
	lea.l	push_decompressed,a3
;decompress data
	move.l	a3,-(sp)
	pea.l	fmovewregto_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a3,a5			;source handle,...
@@:
	add.l	d0,(a3)+		;source handle
	tst.l	(a3)
	bpl	@b
	addq.l	#4,a3			;-1
	movea.l	a3,a0			;expected result,expected status,...
;
55:
	move.l	#",XRN<<4,",d6		;fpcr=(XRN..DRP)<<4
66:
;FPn,Dr=fill
	moveq.l	#$00000000,d3		;fill=$00000000,$FFFFFFFF
33:
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	d3,d1			;fill
					;source
	fmove.w	fp5,d1			;EXECUTE
					;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.W FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',Dr='
	puthex8	d3			;fill
	putmsg	' @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result,expected status,...
;
	not.l	d3			;fill
	bne	33b
;FPn,<mem>=fill
	moveq.l	#$00000000,d3		;fill=$00000000,$FFFFFFFF
33:
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	d3,-(sp)		;fill
					;source
	fmove.w	fp5,(sp)		;EXECUTE
	move.l	(sp)+,d1		;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.W FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',<mem>='
	puthex8	d3			;fill
	putmsg	' @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result,expected status,...
;
	not.l	d3			;fill
	bne	33b
;
	add.w	#1<<4,d6		;rprm++
	cmp.w	#",DRP<<4,",d6		;fpcr=(XRN..DRP)<<4
	bls	66b
;
	addq.l	#4,a5			;source handle
	tst.l	(a5)			;source handle
	bpl	55b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovewregto_data_compressed::
");
  push_start();
  for(i=1,#a,
      x=a[i];  \\ソース
      push_indirect(12,numtoexd(x,RN)));
  push(4,-1);
  for(i=1,#a,
      x=a[i];  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          u=numtoword(x,rm);  \\wordに変換する
          fpsr_update_aer();
          sr=fpsr;
          push(4,0x00000000+u);
          push(4,sr);
          push(4,0xFFFF0000+u);
          push(4,sr);
          push(4,(u<<16)+0x0000);
          push(4,sr);
          push(4,(u<<16)+0xFFFF);
          push(4,sr)));
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.W Dr,FPn
\\  FMOVE.W <mem>,FPn
\\----------------------------------------------------------------------------------------
make_fmovewtoreg()={
  my(a,u,y,rp,rm,sr);
  print("making fmovewtoreg");
  a=DATA_WORD;
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.W Dr,FPn
;	FMOVE.W <mem>,FPn
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovewtoreg_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.W <EA>,FPN'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.W <ea>,FPn',13,10
;------------------------------------------------
;	d1	fpcr=(XRN..DRP)<<4
;	d2	source
;	d3	0=failed,1=successful
;	d5	expected status
;	d7	actual status
;	a2	source,...
;	a4	expected result handle,expected status,...
;	fp5	expected result
;	fp7	actual result
;------------------------------------------------
	lea.l	push_decompressed,a0
;decompress data
	move.l	a0,-(sp)
	pea.l	fmovewtoreg_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a0,a2			;source,...
@@:
	addq.l	#4,a0			;source
	tst.l	(a0)
	bne	@b
	addq.l	#4,a0			;0
	movea.l	a0,a4			;expected result handle,expected status,...
@@:
	add.l	d0,(a0)+		;expected result handle
	addq.l	#4,a0			;expected status
	tst.l	(a0)
	bpl	@b
;	addq.l	#4,a0			;-1
;
22:
	move.l	#",XRN<<4,",d1		;fpcr=(XRN..DRP)<<4
11:
;Dr,FPn
	fmove.l	#0,fpcr
	moveq.l	#0,d2
	move.w	(a2),d2			;source
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
					;source
	fmove.w	d2,fp7			;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	d1,-(sp)		;fpcr
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.W Dr='
	puthex4	d2			;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
;<mem>,FPn
	fmove.l	#0,fpcr
	moveq.l	#0,d2
	move.w	(a2),d2			;source
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.w	d2,-(sp)		;source
	fmove.w	(sp)+,fp7		;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.W <mem>='
	puthex4	d2			;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a4			;expected result
;
	add.w	#1<<4,d1		;rprm++
	cmp.w	#",DRP<<4,",d1		;fpcr=(XRN..DRP)<<4
	bls	11b
;
	addq.l	#4,a2			;source
	tst.l	(a2)			;source
	bne	22b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovewtoreg_data_compressed::
");
  push_start();
  for(i=1,#a,
      u=a[i];  \\ソース
      push(2,u);
      push(2,0));
  push(4,0);
  for(i=1,#a,
      u=a[i];  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          y=wordtonum(u);
          y=roundxxx(y,rp,rm);
          fpsr_update_ccr(y);
          fpsr_update_aer();
          sr=fpsr;
          push_indirect(12,numtoexd(y,RN));
          push(4,sr)));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.X FPn,<mem>
\\----------------------------------------------------------------------------------------
make_fmovexregto()={
  my(a,x,u,rp,rm,sr);
  print("making fmovexregto");
  a=append(DATA_SPECIAL,
           DATA_FLOAT,
           DATA_BASIC,
           DATA_ROUND);
  a=vector(#a,n,exd(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.X FPn,<mem>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovexregto_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.X FPN,<EA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.X FPn,<ea>',13,10
;------------------------------------------------
;	d1-d3	actual result
;	d4	actual status
;	d6	fpcr=(XRN..DRP)<<4
;	d7	0=failed,1=successful
;	a0	expected result handle,expected status,...
;	a1-a3	expected result
;	a4	expected status
;	a5	source handle,...
;	fp5	source
;------------------------------------------------
	lea.l	push_decompressed,a3
;decompress data
	move.l	a3,-(sp)
	pea.l	fmovexregto_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a3,a5			;source handle,...
@@:
	add.l	d0,(a3)+		;source handle
	tst.l	(a3)
	bpl	@b
	addq.l	#4,a3			;-1
	movea.l	a3,a0			;expected result handle,expected status,...
@@:
	add.l	d0,(a3)+		;expected result handle
	addq.l	#4,a3			;expected status
	tst.l	(a3)
	bpl	@b
;	addq.l	#4,a3			;-1
;
55:
	move.l	#",XRN<<4,",d6		;fpcr=(XRN..DRP)<<4
66:
;FPn,<mem>
	fmove.l	#0,fpcr
	fmove.x	([a5]),fp5		;source
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
	move.l	#-1,-(sp)		;fill=-1
	move.l	#-1,-(sp)
	move.l	#-1,-(sp)
					;source
	fmove.x	fp5,(sp)		;EXECUTE
	movem.l	(sp)+,d1-d3		;actual result
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
;
	movem.l	([a0]),a1-a3		;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_packed
	lea.l	32(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.X FPn='
	puthex24	([a5]),(4,[a5]),(8,[a5])	;source
	putmsg	',<mem> @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_packed
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a0			;expected
;
	add.w	#1<<4,d6		;rprm++
	cmp.w	#",DRP<<4,",d6		;fpcr=(XRN..DRP)<<4
	bls	66b
;
	addq.l	#4,a5			;source handle,...
	tst.l	(a5)			;source handle,...
	bpl	55b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovexregto_data_compressed::
");
  push_start();
  for(i=1,#a,
      x=a[i];  \\ソース
      push_indirect(12,numtoexd(x,RN)));
  push(4,-1);
  for(i=1,#a,
      x=a[i];  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          u=numtoexd(x,if(type(x)=="t_POL",RN,rm));  \\extendedに変換する
          fpsr_update_aer();
          sr=fpsr;
          push_indirect(12,u);
          push(4,sr)));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVE.X <mem>,FPn
\\----------------------------------------------------------------------------------------
make_fmovextoreg()={
  my(a,u,y,rp,rm,sr);
  print("making fmovextoreg");
  a=append(DATA_SPECIAL,
           DATA_EXTENDED,
           DATA_BASIC,
           DATA_ROUND);
  a=vector(#a,n,exd(a[n],RN));
  a=uniq(sort(append(a,vector(#a,n,-a[n]),[NaN]),comparator),comparator);
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVE.X <mem>,FPn
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovextoreg_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,-(sp)
	peamsg	'FMOVE.X <EA>,FPN'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVE.X <ea>,FPn',13,10
;------------------------------------------------
;	d1	fpcr=(XRN..DRP)<<4
;	d3	0=failed,1=successful
;	d5	expected status
;	d7	actual status
;	a2	source handle,...
;	a4	expected result handle,expected status,...
;	fp5	expected result
;	fp7	actual result
;------------------------------------------------
	lea.l	push_decompressed,a0
;decompress data
	move.l	a0,-(sp)
	pea.l	fmovextoreg_data_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a0,a2			;source handle,...
@@:
	add.l	d0,(a0)+		;source handle
	tst.l	(a0)
	bpl	@b
	addq.l	#4,a0			;-1
	movea.l	a0,a4			;expected result handle,expected status,...
@@:
	add.l	d0,(a0)+		;expected result handle
	addq.l	#4,a0			;expected status
	tst.l	(a0)
	bpl	@b
;	addq.l	#4,a0			;-1
;
22:
	move.l	#",XRN<<4,",d1		;fpcr=(XRN..DRP)<<4
11:
;<mem>,FPn
	fmove.l	#0,fpcr
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d1,fpcr			;fpcr
	fmove.l	#0,fpsr
					;source
	fmove.x	([a2]),fp7		;EXECUTE
					;actual result
	fmove.l	fpsr,d7			;actual status
	fmove.l	#0,fpcr
;
	fmove.x	([a4]),fp5		;expected result
	move.l	(4,a4),d5		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d3			;0=failed,1=successful
;
	move.l	d3,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVE.X <mem>='
	puthex24	([a2]),(4,[a2]),(8,[a2])	;source
	putmsg	',FPn @'
	move.l	d1,-(sp)
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d3,-(sp)		;0=failed,1=successful
	move.l	d5,-(sp)		;expected status
	fmove.x	fp5,-(sp)		;expected result
	move.l	d7,-(sp)		;actual status
	fmove.x	fp7,-(sp)		;actual result
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a4			;expected result
;
	add.w	#1<<4,d1		;rprm++
	cmp.w	#",DRP<<4,",d1		;fpcr=(XRN..DRP)<<4
	bls	11b
;
	addq.l	#4,a2			;source handle,...
	tst.l	(a2)			;source handle,...
	bpl	22b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts
	.cpu	68000

	.align	4
fmovextoreg_data_compressed::
");
  push_start();
  for(i=1,#a,
      u=numtoexd(a[i],RN);  \\ソース
      push_indirect(12,u));
  push(4,-1);
  for(i=1,#a,
      u=numtoexd(a[i],RN);  \\ソース
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          fpsr=0;
          y=exdtonum(u);
          if((rp==EXD)&&
             ((bitand(u,0x7FFF00008000000000000000)==0)&&
              (bitand(u,0x000000007FFFFFFFFFFFFFFF)!=0)),
             fpsr=bitor(fpsr,UF));  \\丸め桁数がextendedで非正規化数のときUFをセットする
          if(type(y)!="t_POL",
             y=xxx(y,rp,rm));
          fpsr_update_ccr(y);
          fpsr_update_aer();
          sr=fpsr;
          push_indirect(12,numtoexd(y,RN));
          push(4,sr)));
  push(4,-1);
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FMOVECR.X #ccc,FPn
\\----------------------------------------------------------------------------------------
MC68881ROM={[
  Pi,  \\0x00
  0,  \\0x01
  0,  \\0x02
  0,  \\0x03
  0,  \\0x04
  0,  \\0x05
  0,  \\0x06
  0,  \\0x07
  0,  \\0x08
  0,  \\0x09
  0,  \\0x0A
  log10(2),  \\0x0B
  exp(1),  \\0x0C
  log2(exp(1)),  \\0x0D
  log10(exp(1)),  \\0x0E
  0,  \\0x0F
  0,  \\0x10
  0,  \\0x11
  0,  \\0x12
  0,  \\0x13
  0,  \\0x14
  0,  \\0x15
  0,  \\0x16
  0,  \\0x17
  0,  \\0x18
  0,  \\0x19
  0,  \\0x1A
  0,  \\0x1B
  0,  \\0x1C
  0,  \\0x1D
  0,  \\0x1E
  0,  \\0x1F
  0,  \\0x20
  0,  \\0x21
  0,  \\0x22
  0,  \\0x23
  0,  \\0x24
  0,  \\0x25
  0,  \\0x26
  0,  \\0x27
  0,  \\0x28
  0,  \\0x29
  0,  \\0x2A
  0,  \\0x2B
  0,  \\0x2C
  0,  \\0x2D
  0,  \\0x2E
  0,  \\0x2F
  log(2),  \\0x30
  log(10),  \\0x31
  1,  \\0x32
  10,  \\0x33
  10^2,  \\0x34
  10^4,  \\0x35
  10^8,  \\0x36
  10^16,  \\0x37
  10^32,  \\0x38
  10^64,  \\0x39
  10^128,  \\0x3A
  10^256,  \\0x3B
  10^512,  \\0x3C
  10^1024,  \\0x3D
  10^2048,  \\0x3E
  10^4096  \\0x3F
  ]}
make_fmovecr881()={
  my(x,y,rp,rm,sr);
  print("making fmovecr881");
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVECR.X #ccc,FPn
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovecr881_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+FPSP040+FPSP060,-(sp)
	peamsg	'FMOVECR.X #CCC,FPN'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVECR.X #ccc,FPn',13,10
;------------------------------------------------
;	d1-d3	actual result
;	d4	actual status
;	d5	0=failed,1=successful
;	d6	fpcr=(XRN..XRP)<<4
;	d7	ccc=0..63
;	a0	expected result handle,expected status,...
;	a1-a3	expected result
;	a4	expected status
;	fp7	actual result
;------------------------------------------------
	lea.l	push_decompressed,a3
;decompress data
	move.l	a3,-(sp)
	pea.l	fmovecr881_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a3,a0			;expected result handle,expected status,...
@@:
	add.l	d0,(a3)+		;expected result handle
	addq.l	#4,a3			;expected status
	tst.l	(a3)
	bpl	@b
;	addq.l	#4,a3			;-1
;
	moveq.l	#0,d7			;ccc=0..63
77:
	move.l	#",XRN<<4,",d6		;fpcr=(XRN..DRP)<<4
66:
;#ccc,FPn
	fmove.l	#0,fpcr
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
					;ccc
	jsr	([fmovecr881_execute,za0,d7.l*4])	;EXECUTE
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
	fmove.x	fp7,-(sp)
	movem.l	(sp)+,d1-d3		;actual result
;
	movem.l	([a0]),a1-a3		;expected result
	movea.l	(4,a0),a4		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d5			;0=failed,1=successful
;
	move.l	d5,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVECR.X #'
	puthex2	d7			;ccc
	putmsg	',FPn @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d5,-(sp)		;0=failed,1=successful
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a0			;expected result handle,expected status,...
;
	add.w	#1<<4,d6		;rprm++
	cmp.w	#",DRP<<4,",d6		;fpcr=(XRN..DRP)<<4
	bls	66b
;
	addq.w	#1,d7			;ccc++
	cmp.w	#63,d7			;ccc=0..63
	bls	77b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
fmovecr881_execute::
");
  for(ccc=0,63,
      asm(
"	.dc.l	fmovecr881_execute_",ccc,"
");
      );
  for(ccc=0,63,
      asm(
"fmovecr881_execute_",ccc,"::
	fmovecr.x	#",ccc,",fp7
	rts
")
      );
  asm(
"	.cpu	68000

	.align	4
fmovecr881_expected_compressed::
");
  push_start();
  for(ccc=0,63,
      x=MC68881ROM[1+ccc];
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          if((ccc==0x0B)&&(rprm==XRN),
             push_indirect(12,0x3FFD00009A209A84FBCFF798);
             push(4,X2+AX),
             (ccc==0x0C)&&(rprm==XRN),
             push_indirect(12,0x40000000ADF85458A2BB4A9A);
             push(4,X2+AX),
             (ccc==0x0E)&&((rprm==XRN)||(rprm==XRZ)||(rprm==XRM)||(rprm==XRP)),
             push_indirect(12,0x3FFD0000DE5BD8A937287195);
             push(4,0),
             fpsr=0;
             y=roundxxx(x,rp,rm);
             fpsr_update_ccr(y);
             fpsr_update_aer();
             sr=fpsr;
             push_indirect(12,numtoexd(y,RN));
             push(4,sr))));
  push(4,-1);
  push_end()
  }
MC68882ROM={[
  Pi,  \\0x00
  exdtonum(0x40010000FE00068200000000),  \\0x01
  exdtonum(0x40010000FFC0050380000000),  \\0x02
  exdtonum(0x200000007FFFFFFF00000000),  \\0x03
  exdtonum(0x00000000FFFFFFFFFFFFFFFF),  \\0x04
  exdtonum(0x3C000000FFFFFFFFFFFFF800),  \\0x05
  exdtonum(0x3F800000FFFFFF0000000000),  \\0x06
  exdtonum(0x00010000F65D8D9C00000000),  \\0x07
  exdtonum(0x7FFF0000401E000000000000),  \\0x08
  exdtonum(0x43F30000E000000000000000),  \\0x09
  exdtonum(0x40720000C000000000000000),  \\0x0A
  log10(2),  \\0x0B
  exp(1),  \\0x0C
  log2(exp(1)),  \\0x0D
  log10(exp(1)),  \\0x0E
  0,  \\0x0F
  0,  \\0x10
  0,  \\0x11
  0,  \\0x12
  0,  \\0x13
  0,  \\0x14
  0,  \\0x15
  0,  \\0x16
  0,  \\0x17
  0,  \\0x18
  0,  \\0x19
  0,  \\0x1A
  0,  \\0x1B
  0,  \\0x1C
  0,  \\0x1D
  0,  \\0x1E
  0,  \\0x1F
  0,  \\0x20
  0,  \\0x21
  0,  \\0x22
  0,  \\0x23
  0,  \\0x24
  0,  \\0x25
  0,  \\0x26
  0,  \\0x27
  0,  \\0x28
  0,  \\0x29
  0,  \\0x2A
  0,  \\0x2B
  0,  \\0x2C
  0,  \\0x2D
  0,  \\0x2E
  0,  \\0x2F
  log(2),  \\0x30
  log(10),  \\0x31
  1,  \\0x32
  10,  \\0x33
  10^2,  \\0x34
  10^4,  \\0x35
  10^8,  \\0x36
  10^16,  \\0x37
  10^32,  \\0x38
  10^64,  \\0x39
  10^128,  \\0x3A
  10^256,  \\0x3B
  10^512,  \\0x3C
  10^1024,  \\0x3D
  10^2048,  \\0x3E
  10^4096  \\0x3F
  ]}
make_fmovecr882()={
  my(x,y,rp,rm,sr);
  print("making fmovecr882");
  asm(
"
;--------------------------------------------------------------------------------
;	FMOVECR.X #ccc,FPn
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fmovecr882_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68882,-(sp)
	peamsg	'FMOVECR.X #CCC,FPN'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FMOVECR.X #ccc,FPn',13,10
;------------------------------------------------
;	d1-d3	actual result
;	d4	actual status
;	d5	0=failed,1=successful
;	d6	fpcr=(XRN..XRP)<<4
;	d7	ccc=0..63
;	a0	expected result handle,expected status,...
;	a1-a3	expected result
;	a4	expected status
;	fp7	actual result
;------------------------------------------------
	lea.l	push_decompressed,a3
;decompress data
	move.l	a3,-(sp)
	pea.l	fmovecr882_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
;relocate decompressed handle
	move.l	#indirect_decompressed,d0
	movea.l	a3,a0			;expected result handle,expected status,...
@@:
	add.l	d0,(a3)+		;expected result handle
	addq.l	#4,a3			;expected status
	tst.l	(a3)
	bpl	@b
;	addq.l	#4,a3			;-1
;
	moveq.l	#0,d7			;ccc=0..63
77:
	move.l	#",XRN<<4,",d6		;fpcr=(XRN..DRP)<<4
66:
;#ccc,FPn
	fmove.l	#0,fpcr
	fmove.s	#$7FFFFFFF,fp7		;fill=NaN
	fmove.l	d6,fpcr			;fpcr
	fmove.l	#0,fpsr
					;ccc
	jsr	([fmovecr882_execute,za0,d7.l*4])	;EXECUTE
	fmove.l	fpsr,d4			;actual status
	fmove.l	#0,fpcr
	fmove.x	fp7,-(sp)
	movem.l	(sp)+,d1-d3		;actual result
;
	movem.l	([a0]),a1-a3		;expected result
	movea.l	(4,a0),a4		;expected status
;
	move.l	#-1,-(sp)		;fpcr(rp<<6,-1=strict)
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_extended
	lea.l	36(sp),sp
	move.l	d0,d5			;0=failed,1=successful
;
	move.l	d5,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FMOVECR.X #'
	puthex2	d7			;ccc
	putmsg	',FPn @'
	move.l	d6,-(sp)		;fpcr
	jbsr	printfpcrrprm
	addq.l	#4,sp
	putcrlf
	move.l	d5,-(sp)		;0=failed,1=successful
	movem.l	d1-d4/a1-a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_extended
	lea.l	36(sp),sp
@@:
;
	addq.l	#8,a0			;expected result handle,expected status,...
;
	add.w	#1<<4,d6		;rprm++
	cmp.w	#",DRP<<4,",d6		;fpcr=(XRN..DRP)<<4
	bls	66b
;
	addq.w	#1,d7			;ccc++
	cmp.w	#63,d7			;ccc=0..63
	bls	77b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
fmovecr882_execute::
");
  for(ccc=0,63,
      asm(
"	.dc.l	fmovecr882_execute_",ccc,"
");
      );
  for(ccc=0,63,
      asm(
"fmovecr882_execute_",ccc,"::
	fmovecr.x	#",ccc,",fp7
	rts
")
      );
  asm(
"	.cpu	68000

	.align	4
fmovecr882_expected_compressed::
");
  push_start();
  for(ccc=0,63,
      x=MC68882ROM[1+ccc];
      for(rprm=XRN,DRP,  \\(rp<<2)+rm。丸め桁数と丸めモード
          rp=bitand(rprm>>2,3);  \\丸め桁数
          rm=bitand(rprm,3);  \\丸めモード
          if((ccc==0x01)&&((rprm==SRN)||(rprm==SRZ)||(rprm==SRM)),
             push_indirect(12,0x40010000FE00068000000000);
             push(4,X2+AX),
             (ccc==0x02)&&(rprm==SRP),
             push_indirect(12,0x40010000FFC0058000000000);
             push(4,X2+AX),
             (ccc==0x03)&&((rprm==SRN)||(rprm==SRP)),
             push_indirect(12,0x200000008000000000000000);
             push(4,IN+X2+AX),
             (ccc==0x03)&&((rprm==SRZ)||(rprm==SRM)),
             push_indirect(12,0x200000007FFFFF0000000000);
             push(4,NA+X2+AX),
             ccc==0x03,
             push_indirect(12,0x200000007FFFFFFF00000000);
             push(4,NA),
             (ccc==0x07)&&((rprm==SRN)||(rprm==SRZ)||(rprm==SRM)),
             push_indirect(12,0x00010000F65D8D8000000000);
             push(4,NA+X2+AX),
             (ccc==0x07)&&(rprm==SRP),
             push_indirect(12,0x00010000F65D8E0000000000);
             push(4,NA+X2+AX),
             ccc==0x07,
             push_indirect(12,0x00010000F65D8D9C00000000);
             push(4,NA),
             ccc==0x08,
             push_indirect(12,0x7FFF0000401E000000000000);
             push(4,NA),
             (ccc==0x0B)&&(rprm==XRN),
             push_indirect(12,0x3FFD00009A209A84FBCFF798);
             push(4,X2+AX),
             (ccc==0x0C)&&(rprm==XRN),
             push_indirect(12,0x40000000ADF85458A2BB4A9A);
             push(4,X2+AX),
             (ccc==0x0E)&&((rprm==XRN)||(rprm==XRZ)||(rprm==XRM)||(rprm==XRP)),
             push_indirect(12,0x3FFD0000DE5BD8A937287195);
             push(4,0),
             fpsr=0;
             y=roundxxx(x,rp,rm);
             fpsr_update_ccr(y);
             fpsr_update_aer();
             sr=fpsr;
             push_indirect(12,numtoexd(y,RN));
             push(4,sr))));
  push(4,-1);
  push_end()
  }

/*
\\----------------------------------------------------------------------------------------
\\  FMOVEM.L <list>,<ea>
\\----------------------------------------------------------------------------------------
make_fmovemlregto()={
  }


\\----------------------------------------------------------------------------------------
\\  FMOVEM.L <ea>,<list>
\\----------------------------------------------------------------------------------------
make_fmovemltoreg()={
  }


\\----------------------------------------------------------------------------------------
\\  FMOVEM.X #<data>,<ea>
\\  FMOVEM.X <list>,<ea>
\\  FMOVEM.X Dl,<ea>
\\----------------------------------------------------------------------------------------
make_fmovemxregto()={
  }


\\----------------------------------------------------------------------------------------
\\  FMOVEM.X <ea>,#<data>
\\  FMOVEM.X <ea>,<list>
\\  FMOVEM.X <ea>,Dl
\\----------------------------------------------------------------------------------------
make_fmovemxtoreg()={
  }
*/


\\----------------------------------------------------------------------------------------
\\  FMUL.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fmul()={
  make_fop2to1("fmul",
               "fmul",
               -1,
               MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               (x,y,rp,rm)->if((x==NaN)||(y==NaN),NaN,
                               ((x==Rei)||(x==-Rei))&&((y==Inf)||(y==-Inf)),fpsr=bitor(fpsr,OE);NaN,  \\(±0)*(±Inf)=NaN,OE
                               ((x==Inf)||(x==-Inf))&&((y==Rei)||(y==-Rei)),fpsr=bitor(fpsr,OE);NaN,  \\(±Inf)*(±0)=NaN,OE
                               ((x==Rei)||(x==-Rei))&&((y==Rei)||(y==-Rei)),if(x==Rei,1,-1)*if(y==Rei,1,-1)*Rei,  \\(±0)*(±0)=±0
                               ((x==Inf)||(x==-Inf))&&((y==Inf)||(y==-Inf)),if(x==Inf,1,-1)*if(y==Inf,1,-1)*Inf,  \\(±Inf)*(±Inf)=±Inf
                               (y==Rei)||(y==-Rei),sign(x)*if(y==Rei,1,-1)*Rei,  \\(±x)*(±0)=±0
                               (y==Inf)||(y==-Inf),sign(x)*if(y==Inf,1,-1)*Inf,  \\(±x)*(±Inf)=±Inf
                               (x==Rei)||(x==-Rei),if(x==Rei,1,-1)*sign(y)*Rei,  \\(±0)*(±y)=±0
                               (x==Inf)||(x==-Inf),if(x==Inf,1,-1)*sign(y)*Inf,  \\(±Inf)*(±y)=±Inf
                               xxx2(x*y,rp,rm)));
  }


\\----------------------------------------------------------------------------------------
\\  FNEG.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fneg()={
  make_fop1to1("fneg",
               "fneg",
               -1,
               MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,Inf,  \\neg(-Inf)=+Inf
                                x==-Rei,Rei,  \\neg(-0)=+0
                                x==Rei,-Rei,  \\neg(+0)=-0
                                x==Inf,-Inf,  \\neg(+Inf)=-Inf
                                NaN),
                             xxx(-x,rp,rm)))
  }


\\----------------------------------------------------------------------------------------
\\  FREM.X FPm,FPn
\\----------------------------------------------------------------------------------------
frem_func(x,y,rp,rm)={
  my(q,z);
  fpsr=bitand(fpsr,0xFF00FFFF);  \\quotient byteをクリアする
  if((x==NaN)||(y==NaN),NaN,
     (x==Inf)||(x==-Inf),fpsr=bitor(fpsr,OE);NaN,  \\(±Inf)%(±y)=NaN,OE
     (y==Rei)||(y==-Rei),fpsr=bitor(fpsr,OE);NaN,  \\(±x)%(±0)=NaN,OE
     fpsr=bitor(fpsr,bitxor(isminus(x),isminus(y))<<23);  \\商の符号
     if((x==Rei)||(x==-Rei),x,  \\(±0)%(±y)=±0,商は±0
        (y==Inf)||(y==-Inf),xxx(x,rp,rm),  \\(±x)%(±Inf)=±x,商は±0。xが非正規化数のときUFをセットする
        q=rint(x/y);
        fpsr=bitor(fpsr,bitand(abs(q),127)<<16);  \\商の絶対値の下位7bit
        z=xxx(x-q*y,rp,rm);
        if((z==Rei)||(z==-Rei),z=sign(x)*Rei);  \\余りが0のときは0にxの符号を付ける
        z))
  }
make_frem()={
  make_fop2to1("frem",
               "frem",
               -1,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               frem_func)
  }

/*
\\----------------------------------------------------------------------------------------
\\  FRESTORE <ea>
\\----------------------------------------------------------------------------------------
make_frestore()={
  }
*/


\\----------------------------------------------------------------------------------------
\\  FSABS.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fsabs()={
  make_fop1to1("fsabs",
               "fsabs",
               -1,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,Inf,  \\sabs(-Inf)=+Inf
                                x==-Rei,Rei,  \\sabs(-0)=+0
                                x==Rei,Rei,  \\sabs(+0)=+0
                                x==Inf,Inf,  \\sabs(+Inf)=+Inf
                                NaN),
                             sgl(abs(x),rm)))
  }


\\----------------------------------------------------------------------------------------
\\  FSADD.X FPm,FPn
\\----------------------------------------------------------------------------------------
fsadd_func(x,y,rp,rm)={
  my(z);
  if(x==0,x=Rei);
  if(y==0,y=Rei);
  if((x==NaN)||(y==NaN),NaN,
     (x==Inf)&&(y==-Inf),fpsr=bitor(fpsr,OE);NaN,  \\(+Inf)+(-Inf)=NaN,OE
     (x==-Inf)&&(y==Inf),fpsr=bitor(fpsr,OE);NaN,  \\(-Inf)+(+Inf)=NaN,OE
     (x==Rei)&&(y==Rei),Rei,  \\(+0)+(+0)=+0
     (x==-Rei)&&(y==-Rei),-Rei,  \\(-0)+(-0)=-0
     (x==Rei)&&(y==-Rei),if(rm==RM,-Rei,Rei),  \\(+0)+(-0)=±0
     (x==-Rei)&&(y==Rei),if(rm==RM,-Rei,Rei),  \\(-0)+(+0)=±0
     (y==Inf)||(y==-Inf),y,  \\(±x)+(±Inf)=±Inf
     (x==Inf)||(x==-Inf),x,  \\(±Inf)+(±y)=±Inf
     (y==Rei)||(y==-Rei),sgl(x,rm),  \\(±x)+(±0)=(±x)
     (x==Rei)||(x==-Rei),sgl(y,rm),  \\(±0)+(±y)=±y
     z=x+y;
     if(z==0,
        if(rm==RM,-Rei,Rei),
        sgl(z,rm)))
  }
make_fsadd()={
  make_fop2to1("fsadd",
               "fsadd",
               SGL,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               fsadd_func)
  }


/*
\\----------------------------------------------------------------------------------------
\\  FSAVE <ea>
\\----------------------------------------------------------------------------------------
make_fsave()={
  }
*/


\\----------------------------------------------------------------------------------------
\\  FSCALE.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fscale()={
  make_fop2to1("fscale",
               "fscale",
               -1,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               (x,y,rp,rm)->if((x==NaN)||(y==NaN),NaN,  \\NaNと±InfのときOEはセットされない
                               (y==Inf)||(y==-Inf),fpsr=bitor(fpsr,OE);NaN,  \\scale(±x,±Inf)=NaN,OE
                               (x==Inf)||(x==-Inf),x,  \\scale(±Inf,±y)=±Inf
                               (x==Rei)||(x==-Rei),x,  \\scale(±0,±y)=±0
                               (y==Rei)||(y==-Rei),xxx(x,rp,rm),  \\scale(±x,±0)=±x
                               y<-2^14,fpsr=bitor(fpsr,UF+X2);xxx(if(x<0,-Rei,Rei),rp,rm),  \\scale(±x,small)=±0,UF+X2
                               2^14<=y,fpsr=bitor(fpsr,OF);xxx(if(x<0,-Inf,Inf),rp,rm),  \\scale(±x,big)=±Inf,OF
                               xxx2(x*2^trunc(y),rp,rm)))
  }


\\----------------------------------------------------------------------------------------
\\  FScc.B <ea>
\\----------------------------------------------------------------------------------------
make_fscc060()={
  my(m,z,n,a);
  print("making fscc060");
  asm(
"
;--------------------------------------------------------------------------------
;	FScc.B Dr
;	FScc.B <mem>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fscc060_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#FPSP060,-(sp)
	peamsg	'FSCC.B <EA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FScc.B <ea>',13,10
;------------------------------------------------
;	d1	actual result
;	d3	fill=$00000000,$FFFFFFFF
;	d4	actual status
;	d5	cc=0..31
;	d6	fpsr=(mzin=0..15)<<24
;	d7	0=failed,1=successful
;	a0	expected result,expected status,...
;	a1	expected result
;	a4	expected status
;------------------------------------------------
	lea.l	push_decompressed,a0	;expected result,expected status,...
;decompress data
	move.l	a0,-(sp)
	pea.l	fscc060_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
	move.l	#0<<24,d6		;fpsr=(mzin=0..15)<<24
66:
	moveq.l	#0,d5			;cc=0..31
55:
;FScc.B Dr=fill
	moveq.l	#$00000000,d3		;fill=$00000000,$FFFFFFFF
33:
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	move.l	d3,d1			;fill
	jsr	([fscc060_execute_dr,za0,d5.l*4])	;EXECUTE
					;actual result
	fmove.l	fpsr,d4			;actual status
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FS'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	'.B Dr='
	puthex8	d3			;fill
	putmsg	' @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result
;
	not.l	d3			;fill
	bne	33b
;FScc.B <mem>=fill
	moveq.l	#$00000000,d3		;fill=$00000000,$FFFFFFFF
33:
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	move.l	d3,-(sp)		;fill
	jsr	([fscc060_execute_mem,za0,d5.l*4])	;EXECUTE
	move.l	(sp)+,d1		;actual result
	fmove.l	fpsr,d4			;actual status
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FS'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	'.B <mem>='
	puthex8	d3			;fill
	putmsg	' @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result
;
	not.l	d3			;fill
	bne	33b
;
	addq.w	#1,d5			;cc++
	cmp.w	#31,d5			;cc=0..31
	bls	55b
;
	add.l	#1<<24,d6		;mzin++
	cmp.l	#15<<24,d6		;fpsr=(mzin=0..15)<<24
	bls	66b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
fscc060_execute_dr::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	fscc060_execute_dr_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
fscc060_execute_dr_&cc::
	FS&cc.B	d1			;EXECUTE
					;actual result
	rts
  .endm
fscc060_execute_mem::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	fscc060_execute_mem_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
fscc060_execute_mem_&cc::
	FS&cc.B	(4,sp)			;EXECUTE
					;actual result
	rts
  .endm
	.cpu	68000

	.align	4
fscc060_expected_compressed::
");
  push_start();
  for(mzin=0,15,
      m=bitand(mzin>>3,1);
      z=bitand(mzin>>2,1);
      n=bitand(mzin>>0,1);
      a=[
        0xFF*(0),           \\000000  F
        0xFF*(z),           \\000001  EQ
        0xFF*(!(n||z||m)),  \\000010  OGT
        0xFF*(z||!(n||m)),  \\000011  OGE
        0xFF*(m&&!(n||z)),  \\000100  OLT
        0xFF*(z||(m&&!n)),  \\000101  OLE
        0xFF*(!(n||z)),     \\000110  OGL
        0xFF*(!n),          \\000111  OR
        0xFF*(n),           \\001000  UN
        0xFF*(n||z),        \\001001  UEQ
        0xFF*(n||!(m||z)),  \\001010  UGT
        0xFF*(n||(z||!m)),  \\001011  UGE
        0xFF*(n||(m&&!z)),  \\001100  ULT
        0xFF*(n||z||m),     \\001101  ULE
        0xFF*(!z),          \\001110  NE
        0xFF*(1)            \\001111  T
        ];
      for(cc=0,15,
          push(4,0x00000000+a[1+cc]);
          push(4,mzin<<24);
          push(4,0xFFFFFF00+a[1+cc]);
          push(4,mzin<<24);
          push(4,(a[1+cc]<<24)+0x000000);
          push(4,mzin<<24);
          push(4,(a[1+cc]<<24)+0xFFFFFF);
          push(4,mzin<<24));
      for(cc=16,31,
          push(4,0x00000000+a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0));
          push(4,0xFFFFFF00+a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0));
          push(4,(a[1+cc-16]<<24)+0x000000);
          push(4,(mzin<<24)+if(n,BS+AV,0));
          push(4,(a[1+cc-16]<<24)+0xFFFFFF);
          push(4,(mzin<<24)+if(n,BS+AV,0))));
  push_end()
  }
make_fscc88x()={
  my(m,z,n,a);
  print("making fscc88x");
  asm(
"
;--------------------------------------------------------------------------------
;	FScc.B Dr
;	FScc.B <mem>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
fscc88x_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+FPSP040,-(sp)
	peamsg	'FSCC.B <EA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FScc.B <ea>',13,10
;------------------------------------------------
;	d1	actual result
;	d3	fill=$00000000,$FFFFFFFF
;	d4	actual status
;	d5	cc=0..31
;	d6	fpsr=(mzin=0..15)<<24
;	d7	0=failed,1=successful
;	a0	expected result,expected status,...
;	a1	expected result
;	a4	expected status
;------------------------------------------------
	lea.l	push_decompressed,a0	;expected result,expected status,...
;decompress data
	move.l	a0,-(sp)
	pea.l	fscc88x_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
	move.l	#0<<24,d6		;fpsr=(mzin=0..15)<<24
66:
	moveq.l	#0,d5			;cc=0..31
55:
;FScc.B Dr=fill
	moveq.l	#$00000000,d3		;fill=$00000000,$FFFFFFFF
33:
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	move.l	d3,d1			;fill
	jsr	([fscc88x_execute_dr,za0,d5.l*4])	;EXECUTE
					;actual result
	fmove.l	fpsr,d4			;actual status
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FS'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	'.B Dr='
	puthex8	d3			;fill
	putmsg	' @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result
;
	not.l	d3			;fill
	bne	33b
;FScc.B <mem>=fill
	moveq.l	#$00000000,d3		;fill=$00000000,$FFFFFFFF
33:
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	move.l	d3,-(sp)		;fill
	jsr	([fscc88x_execute_mem,za0,d5.l*4])	;EXECUTE
	move.l	(sp)+,d1		;actual result
	fmove.l	fpsr,d4			;actual status
;
	movea.l	(a0),a1			;expected result
	movea.l	(4,a0),a4		;expected status
;
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	test_single
	lea.l	16(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FS'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	'.B <mem>='
	puthex8	d3			;fill
	putmsg	' @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1/d4/a1/a4,-(sp)	;actual result,actual status,expected result,expected status
	jbsr	output_single
	lea.l	20(sp),sp
@@:
;
	addq.l	#8,a0			;expected result
;
	not.l	d3			;fill
	bne	33b
;
	addq.w	#1,d5			;cc++
	cmp.w	#31,d5			;cc=0..31
	bls	55b
;
	add.l	#1<<24,d6		;mzin++
	cmp.l	#15<<24,d6		;fpsr=(mzin=0..15)<<24
	bls	66b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
fscc88x_execute_dr::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	fscc88x_execute_dr_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
fscc88x_execute_dr_&cc::
	FS&cc.B	d1			;EXECUTE
					;actual result
	rts
  .endm
fscc88x_execute_mem::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	fscc88x_execute_mem_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
fscc88x_execute_mem_&cc::
	FS&cc.B	(4,sp)			;EXECUTE
					;actual result
	rts
  .endm
	.cpu	68000

	.align	4
fscc88x_expected_compressed::
");
  push_start();
  for(mzin=0,15,
      m=bitand(mzin>>3,1);
      z=bitand(mzin>>2,1);
      n=bitand(mzin>>0,1);
      a=[
        0xFF*(0),           \\000000  F
        0xFF*(z),           \\000001  EQ
        0xFF*(!(n||z||m)),  \\000010  OGT
        0xFF*(z||!(n||m)),  \\000011  OGE
        0xFF*(m&&!(n||z)),  \\000100  OLT
        0xFF*(z||(m&&!n)),  \\000101  OLE
        0xFF*(!(n||z)),     \\000110  OGL
        0xFF*(z||!n),       \\000111  OR
        0xFF*(n),           \\001000  UN
        0xFF*(n||z),        \\001001  UEQ
        0xFF*(n||!(m||z)),  \\001010  UGT
        0xFF*(n||(z||!m)),  \\001011  UGE
        0xFF*(n||(m&&!z)),  \\001100  ULT
        0xFF*(n||z||m),     \\001101  ULE
        0xFF*(n||!z),       \\001110  NE
        0xFF*(1)            \\001111  T
        ];
      for(cc=0,15,
          push(4,0x00000000+a[1+cc]);
          push(4,mzin<<24);
          push(4,0xFFFFFF00+a[1+cc]);
          push(4,mzin<<24);
          push(4,(a[1+cc]<<24)+0x000000);
          push(4,mzin<<24);
          push(4,(a[1+cc]<<24)+0xFFFFFF);
          push(4,mzin<<24));
      for(cc=16,31,
          push(4,0x00000000+a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0));
          push(4,0xFFFFFF00+a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0));
          push(4,(a[1+cc-16]<<24)+0x000000);
          push(4,(mzin<<24)+if(n,BS+AV,0));
          push(4,(a[1+cc-16]<<24)+0xFFFFFF);
          push(4,(mzin<<24)+if(n,BS+AV,0))));
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FSDIV.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fsdiv()={
  make_fop2to1("fsdiv",
               "fsdiv",
               -1,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               (x,y,rp,rm)->if((x==NaN)||(y==NaN),NaN,
                               ((x==Rei)||(x==-Rei))&&((y==Rei)||(y==-Rei)),fpsr=bitor(fpsr,OE);NaN,  \\(±0)/(±0)=NaN,OE
                               ((x==Inf)||(x==-Inf))&&((y==Inf)||(y==-Inf)),fpsr=bitor(fpsr,OE);NaN,  \\(±Inf)/(±Inf)=NaN,OE
                               ((x==Inf)||(x==-Inf))&&((y==Rei)||(y==-Rei)),if(x==Inf,1,-1)*if(y==Rei,1,-1)*Inf,  \\(±Inf)/(±0)=±Inf,non-DZ
                               ((x==Rei)||(x==-Rei))&&((y==Inf)||(y==-Inf)),if(x==Rei,1,-1)*if(y==Inf,1,-1)*Rei,  \\(±0)/(±Inf)=±0
                               (y==Rei)||(y==-Rei),fpsr=bitor(fpsr,DZ);sign(x)*if(y==Rei,1,-1)*Inf,  \\(±x)/(±0)=±Inf,DZ
                               (y==Inf)||(y==-Inf),sign(x)*if(y==Inf,1,-1)*Rei,  \\(±x)/(±Inf)=±0
                               (x==Rei)||(x==-Rei),if(x==Rei,1,-1)*sign(y)*Rei,  \\(±0)/(±y)=±0
                               (x==Inf)||(x==-Inf),if(x==Inf,1,-1)*sign(y)*Inf,  \\(±Inf)/(±y)=±Inf
                               sgl(x/y,rm)))
  }


\\----------------------------------------------------------------------------------------
\\  FSGLDIV.X FPm,FPn
\\----------------------------------------------------------------------------------------
fsgldiv060_func(x,y,rp,rm)={
  my(z);
  \\引数の仮数部を24bitに切り捨てない
  x=roundexd(x,RZ);
  y=roundexd(y,RZ);
  if((x==NaN)||(y==NaN),NaN,
     ((x==Rei)||(x==-Rei))&&((y==Rei)||(y==-Rei)),fpsr=bitor(fpsr,OE);NaN,  \\(±0)/(±0)=NaN,OE
     ((x==Inf)||(x==-Inf))&&((y==Inf)||(y==-Inf)),fpsr=bitor(fpsr,OE);NaN,  \\(±Inf)/(±Inf)=NaN,OE
     ((x==Inf)||(x==-Inf))&&((y==Rei)||(y==-Rei)),if(x==Inf,1,-1)*if(y==Rei,1,-1)*Inf,  \\(±Inf)/(±0)=±Inf,non-DZ
     ((x==Rei)||(x==-Rei))&&((y==Inf)||(y==-Inf)),if(x==Rei,1,-1)*if(y==Inf,1,-1)*Rei,  \\(±0)/(±Inf)=±0
     (y==Rei)||(y==-Rei),fpsr=bitor(fpsr,DZ);sign(x)*if(y==Rei,1,-1)*Inf,  \\(±x)/(±0)=±Inf,DZ
     (y==Inf)||(y==-Inf),sign(x)*if(y==Inf,1,-1)*Rei,  \\(±x)/(±Inf)=±0
     (x==Rei)||(x==-Rei),if(x==Rei,1,-1)*sign(y)*Rei,  \\(±0)/(±y)=±0
     (x==Inf)||(x==-Inf),if(x==Inf,1,-1)*sign(y)*Inf,  \\(±Inf)/(±y)=±Inf
     z=xsg(x/y,rm);
     \\オーバーフローしたときの返却値を調整する
     \\  アンダーフローしたときの返却値は±XSGDEMINだが、
     \\  オーバーフローしたときの返却値は±EXDNOMAXになる
     \\  このときだけ仮数部が24bitで表現できない値を返す
     if(bitand(fpsr,OF),
        if(abs(z)==XSGNOMAX,
           z=sign(z)*EXDNOMAX));
     z)
  }
make_fsgldiv060()={
  make_fop2to1("fsgldiv060",
               "fsgldiv",
               -1,  \\仮数部が24bitで表現できない値を返す場合があるのでSGLは不可
               MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               fsgldiv060_func)
  }
fsgldiv88x_func(x,y,rp,rm)={
  my(z);
  \\引数の仮数部を24bitに切り捨てない
  x=roundexd(x,RZ);
  y=roundexd(y,RZ);
  if((x==NaN)||(y==NaN),NaN,
     ((x==Rei)||(x==-Rei))&&((y==Rei)||(y==-Rei)),fpsr=bitor(fpsr,OE);NaN,  \\(±0)/(±0)=NaN,OE
     ((x==Inf)||(x==-Inf))&&((y==Inf)||(y==-Inf)),fpsr=bitor(fpsr,OE);NaN,  \\(±Inf)/(±Inf)=NaN,OE
     ((x==Inf)||(x==-Inf))&&((y==Rei)||(y==-Rei)),if(x==Inf,1,-1)*if(y==Rei,1,-1)*Inf,  \\(±Inf)/(±0)=±Inf,non-DZ
     ((x==Rei)||(x==-Rei))&&((y==Inf)||(y==-Inf)),if(x==Rei,1,-1)*if(y==Inf,1,-1)*Rei,  \\(±0)/(±Inf)=±0
     (y==Rei)||(y==-Rei),fpsr=bitor(fpsr,DZ);sign(x)*if(y==Rei,1,-1)*Inf,  \\(±x)/(±0)=±Inf,DZ
     (y==Inf)||(y==-Inf),sign(x)*if(y==Inf,1,-1)*Rei,  \\(±x)/(±Inf)=±0
     (x==Rei)||(x==-Rei),if(x==Rei,1,-1)*sign(y)*Rei,  \\(±0)/(±y)=±0
     (x==Inf)||(x==-Inf),if(x==Inf,1,-1)*sign(y)*Inf,  \\(±Inf)/(±y)=±Inf
     z=xsg(x/y,rm);
     if(TEST_HARD_FSGLDIV,
        \\アンダーフローしたときの返却値を調整する
        \\  RPまたはRMなのに絶対値が切り上げられず、不正確な結果なのにX2がセットされないことがある
        \\    RP,0x000000000000000000000001,0x3ffd00008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\    RP,0x000000000000000000000001,0x3ffe00008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\    RP,0x000000000000000000000001,0x3fff00008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\    RP,0x000000000000000000000001,0x400000008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\    RP,0x000000000000000000000001,0x400100008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\!!! テストした範囲のみ
        if(bitand(fpsr,UF),
           \\FSGLMULと異なり、3/4,3/2,3は含まれない
           if((abs(x)==EXDDEMIN)&&((abs(y)==1/4)||(abs(y)==1/2)||(abs(y)==1)||(abs(y)==2)||(abs(y)==4)),
              z=if(x*y<0,-Rei,Rei);
              fpsr=UF)));
     \\オーバーフローしたときの返却値を調整する
     \\  アンダーフローしたときの返却値は±XSGDEMINだが、
     \\  オーバーフローしたときの返却値は±EXDNOMAXになる
     \\  このときだけ仮数部が24bitで表現できない値を返す
     if(bitand(fpsr,OF),
        if(abs(z)==XSGNOMAX,
           z=sign(z)*EXDNOMAX));
     z)
  }
make_fsgldiv88x()={
  make_fop2to1("fsgldiv88x",
               "fsgldiv",
               -1,  \\仮数部が24bitで表現できない値を返す場合があるのでSGLは不可
               MC68881+MC68882+FPSP040,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               fsgldiv88x_func)
  }


\\----------------------------------------------------------------------------------------
\\  FSGLMUL.X FPm,FPn
\\----------------------------------------------------------------------------------------
fsglmul060_func(x,y,rp,rm)={
  my(z);
  \\引数の仮数部を24bitに切り捨てる
  \\  このときEXDDEMINをReiにしてはならない
  \\  Inf*EXDDEMIN=Infであり、Inf*Rei=NaN,OEではない
  x=roundsgl(x,RZ);
  y=roundsgl(y,RZ);
  fpsr=0;
  if((x==NaN)||(y==NaN),NaN,
     ((x==Rei)||(x==-Rei))&&((y==Inf)||(y==-Inf)),fpsr=bitor(fpsr,OE);NaN,  \\(±0)*(±Inf)=NaN,OE
     ((x==Inf)||(x==-Inf))&&((y==Rei)||(y==-Rei)),fpsr=bitor(fpsr,OE);NaN,  \\(±Inf)*(±0)=NaN,OE
     ((x==Rei)||(x==-Rei))&&((y==Rei)||(y==-Rei)),if(x==Rei,1,-1)*if(y==Rei,1,-1)*Rei,  \\(±0)*(±0)=±0
     ((x==Inf)||(x==-Inf))&&((y==Inf)||(y==-Inf)),if(x==Inf,1,-1)*if(y==Inf,1,-1)*Inf,  \\(±Inf)*(±Inf)=±Inf
     (y==Rei)||(y==-Rei),sign(x)*if(y==Rei,1,-1)*Rei,  \\(±x)*(±0)=±0
     (y==Inf)||(y==-Inf),sign(x)*if(y==Inf,1,-1)*Inf,  \\(±x)*(±Inf)=±Inf
     (x==Rei)||(x==-Rei),if(x==Rei,1,-1)*sign(y)*Rei,  \\(±0)*(±y)=±0
     (x==Inf)||(x==-Inf),if(x==Inf,1,-1)*sign(y)*Inf,  \\(±Inf)*(±y)=±Inf
     z=xsg(x*y,rm);
     \\オーバーフローしたときの返却値を調整する
     \\  アンダーフローしたときの返却値は±XSGDEMINだが、
     \\  オーバーフローしたときの返却値は±EXDNOMAXになる
     \\  このときだけ仮数部が24bitで表現できない値を返す
     if(bitand(fpsr,OF),
        if(abs(z)==XSGNOMAX,
           z=sign(z)*EXDNOMAX));
     z)
  }
make_fsglmul060()={
  make_fop2to1("fsglmul060",
               "fsglmul",
               -1,  \\仮数部が24bitで表現できない値を返す場合があるのでSGLは不可
               MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               fsglmul060_func)
  }
fsglmul88x_func(x,y,rp,rm)={
  my(z);
  \\引数の仮数部を24bitに切り捨てる
  \\  このときEXDDEMINをReiにしてはならない
  \\  Inf*EXDDEMIN=Infであり、Inf*Rei=NaN,OEではない
  x=roundsgl(x,RZ);
  y=roundsgl(y,RZ);
  fpsr=0;
  if((x==NaN)||(y==NaN),NaN,
     ((x==Rei)||(x==-Rei))&&((y==Inf)||(y==-Inf)),fpsr=bitor(fpsr,OE);NaN,  \\(±0)*(±Inf)=NaN,OE
     ((x==Inf)||(x==-Inf))&&((y==Rei)||(y==-Rei)),fpsr=bitor(fpsr,OE);NaN,  \\(±Inf)*(±0)=NaN,OE
     ((x==Rei)||(x==-Rei))&&((y==Rei)||(y==-Rei)),if(x==Rei,1,-1)*if(y==Rei,1,-1)*Rei,  \\(±0)*(±0)=±0
     ((x==Inf)||(x==-Inf))&&((y==Inf)||(y==-Inf)),if(x==Inf,1,-1)*if(y==Inf,1,-1)*Inf,  \\(±Inf)*(±Inf)=±Inf
     (y==Rei)||(y==-Rei),sign(x)*if(y==Rei,1,-1)*Rei,  \\(±x)*(±0)=±0
     (y==Inf)||(y==-Inf),sign(x)*if(y==Inf,1,-1)*Inf,  \\(±x)*(±Inf)=±Inf
     (x==Rei)||(x==-Rei),if(x==Rei,1,-1)*sign(y)*Rei,  \\(±0)*(±y)=±0
     (x==Inf)||(x==-Inf),if(x==Inf,1,-1)*sign(y)*Inf,  \\(±Inf)*(±y)=±Inf
     z=xsg(x*y,rm);
     if(TEST_HARD_FSGLMUL,
        \\アンダーフローしたときの返却値を調整する
        \\  RPまたはRMなのに絶対値が切り上げられず、不正確な結果なのにX2がセットされないことがある
        \\    RP,0x000000000000000000000001,0x000000000000000000000001
        \\       0x000000000000010000000000,UF+X2+AU+AX	;expected
        \\    RP,0x000000000000000000000001,0x3bcd00008000000000000000
        \\       0x000000000000010000000000,UF+X2+AU+AX	;expected
        \\    RP,0x000000000000000000000001,0x3ffd00008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\    RP,0x000000000000000000000001,0x3ffe00008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\    RP,0x000000000000000000000001,0x3fff00008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\    RP,0x000000000000000000000001,0x400000008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\    RP,0x000000000000000000000001,0x400100008000000000000000
        \\       0x000000000000000000000000,ZE+UF	;expected
        \\!!! テストした範囲のみ
        if(bitand(fpsr,UF),
           \\FSGLDIVと異なり、3/4,3/2,3が含まれる
           if(((abs(x)==EXDDEMIN)&&((abs(y)==1/4)||(abs(y)==1/2)||(abs(y)==1)||(abs(y)==2)||(abs(y)==4)||
                                    (abs(y)==3/4)||(abs(y)==3/2)||(abs(y)==3)))||
              ((abs(y)==EXDDEMIN)&&((abs(x)==1/4)||(abs(x)==1/2)||(abs(x)==1)||(abs(x)==2)||(abs(x)==4)||
                                    (abs(x)==3/4)||(abs(x)==3/2)||(abs(x)==3))),
              z=if(x*y<0,-Rei,Rei);
              fpsr=UF)));
     \\オーバーフローしたときの返却値を調整する
     \\  アンダーフローしたときの返却値は±XSGDEMINだが、
     \\  オーバーフローしたときの返却値は±EXDNOMAXになる
     \\  このときだけ仮数部が24bitで表現できない値を返す
     if(bitand(fpsr,OF),
        if(abs(z)==XSGNOMAX,
           z=sign(z)*EXDNOMAX));
     z)
  }
make_fsglmul88x()={
  make_fop2to1("fsglmul88x",
               "fsglmul",
               -1,  \\仮数部が24bitで表現できない値を返す場合があるのでSGLは不可
               MC68881+MC68882+FPSP040,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               fsglmul88x_func)
  }


\\----------------------------------------------------------------------------------------
\\  FSIN.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fsin()={
  my(y);
  make_fop1to1("fsin",
               "fsin",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_TRIGONOMETRIC),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\sin(-Inf)=NaN,OE
                                x==-Rei,-Rei,  \\sin(-0)=-0
                                x==Rei,Rei,  \\sin(+0)=+0
                                x==Inf,fpsr=bitor(fpsr,OE);NaN,  \\sin(+Inf)=NaN,OE
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             y=roundxxx(sin(x),rp,rm);
                             y=originUpperLower(y,x,rp,rm);
                             y=xxx(y,rp,rm);
                             correctUnderflow(y,rp)))
  }


\\----------------------------------------------------------------------------------------
\\  FSINCOS.X FPm,FPc:FPs
\\----------------------------------------------------------------------------------------
make_fsincos()={
  my(y);
  make_fop1to2("fsincos",
               "fsincos",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_TRIGONOMETRIC),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\cos(-Inf)=NaN,OE
                                x==-Rei,1,  \\cos(-0)=1
                                x==Rei,1,  \\cos(+0)=1
                                x==Inf,fpsr=bitor(fpsr,OE);NaN,  \\cos(+Inf)=NaN,OE
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             y=roundxxx(cos(x),rp,rm);
                             if(type(y)!="t_POL",
                                if(y==1,if((rm==RZ)||(rm==RM),y=nextdown(1,rp)));
                                if(y==-1,if((rm==RZ)||(rm==RP),y=nextup(1,rp))));
                             xxx(y,rp,rm)),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\sin(-Inf)=NaN,OE
                                x==-Rei,-Rei,  \\sin(-0)=-0
                                x==Rei,Rei,  \\sin(+0)=+0
                                x==Inf,fpsr=bitor(fpsr,OE);NaN,  \\sin(+Inf)=NaN,OE
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             y=roundxxx(sin(x),rp,rm);
                             y=originUpperLower(y,x,rp,rm);
                             y=xxx(y,rp,rm);
                             correctUnderflow(y,rp)))
  }


\\----------------------------------------------------------------------------------------
\\  FSINH.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fsinh()={
  my(y);
  make_fop1to1("fsinh",
               "fsinh",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,-Inf,  \\sinh(-Inf)=-Inf
                                x==-Rei,-Rei,  \\sinh(-0)=-0
                                x==Rei,Rei,  \\sinh(+0)=+0
                                x==Inf,Inf,  \\sinh(+Inf)=+Inf
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             if(x<=-65536,fpsr=bitor(fpsr,OF);xxx(-Inf,rp,rm),  \\sinh(-big)=-Inf,OF
                                65536<=x,fpsr=bitor(fpsr,OF);xxx(Inf,rp,rm),  \\sinh(+big)=+Inf,OF
                                y=roundxxx(sinh(x),rp,rm);
                                y=originLowerUpper(y,x,rp,rm);
                                y=xxx(y,rp,rm);
                                correctUnderflow(y,rp))))
  }


\\----------------------------------------------------------------------------------------
\\  FSMOVE.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fsmove()={
  make_fop1to1("fsmove",
               "fsmove",
               -1,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,-Inf,  \\smove(-Inf)=-Inf
                                x==-Rei,-Rei,  \\smove(-0)=-0
                                x==Rei,Rei,  \\smove(+0)=+0
                                x==Inf,Inf,  \\smove(+Inf)=+Inf
                                NaN),
                             sgl(x,rm)))
  }


\\----------------------------------------------------------------------------------------
\\  FSMUL.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fsmul()={
  make_fop2to1("fsmul",
               "fsmul",
               -1,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               (x,y,rp,rm)->if((x==NaN)||(y==NaN),NaN,
                               ((x==Rei)||(x==-Rei))&&((y==Inf)||(y==-Inf)),fpsr=bitor(fpsr,OE);NaN,  \\(±0)*(±Inf)=NaN,OE
                               ((x==Inf)||(x==-Inf))&&((y==Rei)||(y==-Rei)),fpsr=bitor(fpsr,OE);NaN,  \\(±Inf)*(±0)=NaN,OE
                               ((x==Rei)||(x==-Rei))&&((y==Rei)||(y==-Rei)),if(x==Rei,1,-1)*if(y==Rei,1,-1)*Rei,  \\(±0)*(±0)=±0
                               ((x==Inf)||(x==-Inf))&&((y==Inf)||(y==-Inf)),if(x==Inf,1,-1)*if(y==Inf,1,-1)*Inf,  \\(±Inf)*(±Inf)=±Inf
                               (y==Rei)||(y==-Rei),sign(x)*if(y==Rei,1,-1)*Rei,  \\(±x)*(±0)=±0
                               (y==Inf)||(y==-Inf),sign(x)*if(y==Inf,1,-1)*Inf,  \\(±x)*(±Inf)=±Inf
                               (x==Rei)||(x==-Rei),if(x==Rei,1,-1)*sign(y)*Rei,  \\(±0)*(±y)=±0
                               (x==Inf)||(x==-Inf),if(x==Inf,1,-1)*sign(y)*Inf,  \\(±Inf)*(±y)=±Inf
                               sgl(x*y,rm)));
  }


\\----------------------------------------------------------------------------------------
\\  FSNEG.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fsneg()={
  make_fop1to1("fsneg",
               "fsneg",
               -1,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,Inf,  \\sneg(-Inf)=+Inf
                                x==-Rei,Rei,  \\sneg(-0)=+0
                                x==Rei,-Rei,  \\sneg(+0)=-0
                                x==Inf,-Inf,  \\sneg(+Inf)=-Inf
                                NaN),
                             sgl(-x,rm)))
  }


\\----------------------------------------------------------------------------------------
\\  FSQRT.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fsqrt()={
  my(y);
  make_fop1to1("fsqrt",
               "fsqrt",
               -1,
               MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_ONE_MINUS,
                      DATA_ONE_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\sqrt(-Inf)=NaN,OE
                                x==-Rei,-Rei,  \\sqrt(-0)=-0
                                x==Rei,Rei,  \\sqrt(+0)=+0
                                x==Inf,Inf,  \\sqrt(+Inf)=+Inf
                                NaN),
                             if(x<0,fpsr=bitor(fpsr,OE);NaN,  \\sqrt(-x)=NaN,OE
                                y=xxx(sqrt(x),rp,rm);
                                if(y^2!=x,fpsr=bitor(fpsr,X2));
                                y)))
  }


\\----------------------------------------------------------------------------------------
\\  FSSQRT.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fssqrt()={
  my(y);
  make_fop1to1("fssqrt",
               "fssqrt",
               -1,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_ONE_MINUS,
                      DATA_ONE_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\ssqrt(-Inf)=NaN,OE
                                x==-Rei,-Rei,  \\ssqrt(-0)=-0
                                x==Rei,Rei,  \\ssqrt(+0)=+0
                                x==Inf,Inf,  \\ssqrt(+Inf)=+Inf
                                NaN),
                             if(x<0,fpsr=bitor(fpsr,OE);NaN,  \\ssqrt(-x)=NaN,OE
                                y=sgl(sqrt(x),rm);
                                if(y^2!=x,fpsr=bitor(fpsr,X2));
                                y)))
  }


\\----------------------------------------------------------------------------------------
\\  FSSUB.X FPm,FPn
\\----------------------------------------------------------------------------------------
fssub_func(x,y,rp,rm)={
  my(z);
  if(x==0,x=Rei);
  if(y==0,y=Rei);
  if((x==NaN)||(y==NaN),NaN,
     (x==Inf)&&(y==Inf),fpsr=bitor(fpsr,OE);NaN,  \\(+Inf)-(+Inf)=NaN,OE
     (x==-Inf)&&(y==-Inf),fpsr=bitor(fpsr,OE);NaN,  \\(-Inf)-(-Inf)=NaN,OE
     (x==Rei)&&(y==-Rei),Rei,  \\(+0)-(-0)=+0
     (x==-Rei)&&(y==Rei),-Rei,  \\(-0)-(+0)=-0
     (x==Rei)&&(y==Rei),if(rm==RM,-Rei,Rei),  \\(+0)-(+0)=±0
     (x==-Rei)&&(y==-Rei),if(rm==RM,-Rei,Rei),  \\(-0)-(-0)=±0
     (y==Inf)||(y==-Inf),-y,  \\(±x)-(±Inf)=∓Inf
     (x==Inf)||(x==-Inf),x,  \\(±Inf)-(±y)=±Inf
     (y==Rei)||(y==-Rei),sgl(x,rm),  \\(±x)-(±0)=(±x)
     (x==Rei)||(x==-Rei),sgl(-y,rm),  \\(±0)-(±y)=∓y
     z=x-y;
     if(z==0,
        if(rm==RM,-Rei,Rei),
        sgl(z,rm)))
  }
make_fssub()={
  make_fop2to1("fssub",
               "fssub",
               -1,
               MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               fssub_func)
  }


\\----------------------------------------------------------------------------------------
\\  FSUB.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_fsub()={
  my(z);
  make_fop2to1("fsub",
               "fsub",
               -1,
               MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_EXTENDED,
                      DATA_BINARY),
               (x,y,rp,rm)->if((x==NaN)||(y==NaN),NaN,
                               (x==Inf)&&(y==Inf),fpsr=bitor(fpsr,OE);NaN,  \\(+Inf)-(+Inf)=NaN,OE
                               (x==-Inf)&&(y==-Inf),fpsr=bitor(fpsr,OE);NaN,  \\(-Inf)-(-Inf)=NaN,OE
                               (x==Rei)&&(y==-Rei),Rei,  \\(+0)-(-0)=+0
                               (x==-Rei)&&(y==Rei),-Rei,  \\(-0)-(+0)=-0
                               (x==Rei)&&(y==Rei),if(rm==RM,-Rei,Rei),  \\(+0)-(+0)=±0
                               (x==-Rei)&&(y==-Rei),if(rm==RM,-Rei,Rei),  \\(-0)-(-0)=±0
                               (y==Inf)||(y==-Inf),-y,  \\(±x)-(±Inf)=∓Inf
                               (x==Inf)||(x==-Inf),x,  \\(±Inf)-(±y)=±Inf
                               z=xxx(if((x==Rei)||(x==-Rei),0,x)-
                                     if((y==Rei)||(y==-Rei),0,y),rp,rm);  \\(±x)-(±0)=±x,(±0)-(±y)=∓y
                               if((z==Rei)||(z==-Rei),z=if(rm==RM,-Rei,Rei));
                               z))
  }


\\----------------------------------------------------------------------------------------
\\  FTAN.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_ftan()={
  my(y);
  make_fop1to1("ftan",
               "ftan",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS,
                      DATA_TRIGONOMETRIC),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,fpsr=bitor(fpsr,OE);NaN,  \\tan(-Inf)=NaN,OE
                                x==-Rei,-Rei,  \\tan(-0)=-0
                                x==Rei,Rei,  \\tan(+0)=+0
                                x==Inf,fpsr=bitor(fpsr,OE);NaN,  \\tan(+Inf)=NaN,OE
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             y=roundxxx(tan(x),rp,rm);
                             y=originLowerUpper(y,x,rp,rm);
                             y=xxx(y,rp,rm);
                             correctUnderflow(y,rp)))
  }


\\----------------------------------------------------------------------------------------
\\  FTANH.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_ftanh()={
  my(y);
  make_fop1to1("ftanh",
               "ftanh",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,-1,  \\tanh(-Inf)=-1
                                x==-Rei,-Rei,  \\tanh(-0)=-0
                                x==Rei,Rei,  \\tanh(+0)=+0
                                x==Inf,1,  \\tanh(+Inf)=+1
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             if(x<=-256,if((rm==RZ)||(rm==RP),nextup(-1,rp),-1),  \\tanh(-big)=-1
                                256<=x,if((rm==RZ)||(rm==RM),nextdown(1,rp),1),  \\tanh(+big)=+1
                                y=roundxxx(tanh(x),rp,rm);
                                y=originUpperLower(y,x,rp,rm);
                                y=xxx(y,rp,rm);
                                correctUnderflow(y,rp))))
  }


\\----------------------------------------------------------------------------------------
\\  FTENTOX.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_ftentox()={
  make_fop1to1("ftentox",
               "ftentox",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,Rei,  \\tentox(-Inf)=+0
                                x==-Rei,1,  \\tentox(-0)=1
                                x==Rei,1,  \\tentox(+0)=1
                                x==Inf,Inf,  \\tentox(+Inf)=+Inf
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             if(x<=-65536,fpsr=bitor(fpsr,UF);xxx(Rei,rp,rm),  \\tentox(-big)=+0,UF
                                65536<x,fpsr=bitor(fpsr,OF);xxx(Inf,rp,rm),  \\tentox(+big)=+Inf,OF
                                xxx(10^x,rp,rm))))
  }


\\----------------------------------------------------------------------------------------
\\  FTRAPcc
\\----------------------------------------------------------------------------------------
make_ftrapcc060()={
  my(m,z,n,a);
  print("making ftrapcc060");
  asm(
"
;--------------------------------------------------------------------------------
;	FTRAPcc
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
ftrapcc060_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#FPSP060,-(sp)
	peamsg	'FTRAPCC'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FTRAPcc',13,10
;------------------------------------------------
;	d1	actual result upper
;	d2	actual result lower
;	d3	actual status
;	d5	cc=0..31
;	d6	fpsr=(mzin=0..15)<<24
;	d7	0=failed,1=successful
;	a0	expected result upper,expected result lower,expected status,...
;	a1	expected result upper
;	a2	expected result lower
;	a3	expected status
;------------------------------------------------
	lea.l	push_decompressed,a0	;expected result upper,expected result lower,expected status,...
;decompress data
	move.l	a0,-(sp)
	pea.l	ftrapcc060_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
	move.l	#0<<24,d6		;fpsr=(mzin=0..15)<<24
66:
	moveq.l	#0,d5			;cc=0..31
55:
;FTRAPcc
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	clr.l	trapv_occurred		;actual result upper
	jsr	([ftrapcc060_execute,za0,d5.l*4])	;EXECUTE
					;actual result lower
	move.l	trapv_occurred,d2	;actual result upper
	fmove.l	fpsr,d3			;actual status
;
	movem.l	(a0),a1-a3		;expected result upper,expected result lower,expected status
;
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	test_double
	lea.l	24(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FTRAP'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	' @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	output_double
	lea.l	28(sp),sp
@@:
;
	lea.l	(12,a0),a0		;expected result upper,expected result lower,expected status,...
;
	addq.w	#1,d5			;cc++
	cmp.w	#31,d5			;cc=0..31
	bls	55b
;
	add.l	#1<<24,d6		;mzin++
	cmp.l	#15<<24,d6		;fpsr=(mzin=0..15)<<24
	bls	66b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
ftrapcc060_execute::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	ftrapcc060_execute_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
ftrapcc060_execute_&cc::
	moveq.l	#3,d1			;actual result upper. 3=too long
	FTRAP&cc			;EXECUTE
	subq.l	#1,d1			;actual result upper. 0=ok
	subq.l	#1,d1			;actual result upper. 1=too long
	subq.l	#1,d1			;actual result upper. 2=too long
	rts
  .endm
	.cpu	68000

	.align	4
ftrapcc060_expected_compressed::
");
  push_start();
  for(mzin=0,15,
      m=bitand(mzin>>3,1);
      z=bitand(mzin>>2,1);
      n=bitand(mzin>>0,1);
      a=[
        0,           \\000000  F
        z,           \\000001  EQ
        !(n||z||m),  \\000010  OGT
        z||!(n||m),  \\000011  OGE
        m&&!(n||z),  \\000100  OLT
        z||(m&&!n),  \\000101  OLE
        !(n||z),     \\000110  OGL
        !n,          \\000111  OR
        n,           \\001000  UN
        n||z,        \\001001  UEQ
        n||!(m||z),  \\001010  UGT
        n||(z||!m),  \\001011  UGE
        n||(m&&!z),  \\001100  ULT
        n||z||m,     \\001101  ULE
        !z,          \\001110  NE
        1            \\001111  T
        ];
      for(cc=0,15,
          push(4,0);
          push(4,a[1+cc]);
          push(4,mzin<<24));
      for(cc=16,31,
          push(4,0);
          push(4,a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0))));
  push_end()
  }
make_ftrapcc88x()={
  my(m,z,n,a);
  print("making ftrapcc88x");
  asm(
"
;--------------------------------------------------------------------------------
;	FTRAPcc
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
ftrapcc88x_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040,-(sp)
	peamsg	'FTRAPCC'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FTRAPcc',13,10
;------------------------------------------------
;	d1	actual result upper
;	d2	actual result lower
;	d3	actual status
;	d5	cc=0..31
;	d6	fpsr=(mzin=0..15)<<24
;	d7	0=failed,1=successful
;	a0	expected result upper,expected result lower,expected status,...
;	a1	expected result upper
;	a2	expected result lower
;	a3	expected status
;------------------------------------------------
	lea.l	push_decompressed,a0	;expected result upper,expected result lower,expected status,...
;decompress data
	move.l	a0,-(sp)
	pea.l	ftrapcc88x_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
	move.l	#0<<24,d6		;fpsr=(mzin=0..15)<<24
66:
	moveq.l	#0,d5			;cc=0..31
55:
;FTRAPcc
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	clr.l	trapv_occurred		;actual result lower
	jsr	([ftrapcc88x_execute,za0,d5.l*4])	;EXECUTE
					;actual result upper
	move.l	trapv_occurred,d2	;actual result lower
	fmove.l	fpsr,d3			;actual status
;
	movem.l	(a0),a1-a3		;expected result upper,expected result lower,expected status
;
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	test_double
	lea.l	24(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FTRAP'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	' @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	output_double
	lea.l	28(sp),sp
@@:
;
	lea.l	(12,a0),a0		;expected result upper,expected result lower,expected status,...
;
	addq.w	#1,d5			;cc++
	cmp.w	#31,d5			;cc=0..31
	bls	55b
;
	add.l	#1<<24,d6		;mzin++
	cmp.l	#15<<24,d6		;fpsr=(mzin=0..15)<<24
	bls	66b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
ftrapcc88x_execute::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	ftrapcc88x_execute_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
ftrapcc88x_execute_&cc::
	moveq.l	#3,d1			;actual result upper. 3=too long
	FTRAP&cc			;EXECUTE
	subq.l	#1,d1			;actual result upper. 0=ok
	subq.l	#1,d1			;actual result upper. 1=too long
	subq.l	#1,d1			;actual result upper. 2=too long
	rts
  .endm
	.cpu	68000

	.align	4
ftrapcc88x_expected_compressed::
");
  push_start();
  for(mzin=0,15,
      m=bitand(mzin>>3,1);
      z=bitand(mzin>>2,1);
      n=bitand(mzin>>0,1);
      a=[
        0,           \\000000  F
        z,           \\000001  EQ
        !(n||z||m),  \\000010  OGT
        z||!(n||m),  \\000011  OGE
        m&&!(n||z),  \\000100  OLT
        z||(m&&!n),  \\000101  OLE
        !(n||z),     \\000110  OGL
        z||!n,       \\000111  OR
        n,           \\001000  UN
        n||z,        \\001001  UEQ
        n||!(m||z),  \\001010  UGT
        n||(z||!m),  \\001011  UGE
        n||(m&&!z),  \\001100  ULT
        n||z||m,     \\001101  ULE
        n||!z,       \\001110  NE
        1            \\001111  T
        ];
      for(cc=0,15,
          push(4,0);
          push(4,a[1+cc]);
          push(4,mzin<<24));
      for(cc=16,31,
          push(4,0);
          push(4,a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0))));
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FTRAPcc.L #<data>
\\----------------------------------------------------------------------------------------
make_ftrapccl060()={
  my(m,z,n,a);
  print("making ftrapccl060");
  asm(
"
;--------------------------------------------------------------------------------
;	FTRAPcc.L #<data>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
ftrapccl060_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#FPSP060,-(sp)
	peamsg	'FTRAPCC.L #<DATA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FTRAPcc.L #<data>',13,10
;------------------------------------------------
;	d1	actual result upper
;	d2	actual result lower
;	d3	actual status
;	d5	cc=0..31
;	d6	fpsr=(mzin=0..15)<<24
;	d7	0=failed,1=successful
;	a0	expected result upper,expected result lower,expected status,...
;	a1	expected result upper
;	a2	expected result lower
;	a3	expected status
;------------------------------------------------
	lea.l	push_decompressed,a0	;expected result upper,expected result lower,expected status,...
;decompress data
	move.l	a0,-(sp)
	pea.l	ftrapccl060_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
	move.l	#0<<24,d6		;fpsr=(mzin=0..15)<<24
66:
	moveq.l	#0,d5			;cc=0..31
55:
;FTRAPcc.L #<data>
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	clr.l	trapv_occurred		;actual result upper
	jsr	([ftrapccl060_execute,za0,d5.l*4])	;EXECUTE
					;actual result lower
	move.l	trapv_occurred,d2	;actual result upper
	fmove.l	fpsr,d3			;actual status
;
	movem.l	(a0),a1-a3		;expected result upper,expected result lower,expected status
;
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	test_double
	lea.l	24(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FTRAP'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	'.L #<data> @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	output_double
	lea.l	28(sp),sp
@@:
;
	lea.l	(12,a0),a0		;expected result upper,expected result lower,expected status,...
;
	addq.w	#1,d5			;cc++
	cmp.w	#31,d5			;cc=0..31
	bls	55b
;
	add.l	#1<<24,d6		;mzin++
	cmp.l	#15<<24,d6		;fpsr=(mzin=0..15)<<24
	bls	66b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
ftrapccl060_execute::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	ftrapccl060_execute_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
ftrapccl060_execute_&cc::
	moveq.l	#3,d1			;actual result upper. 3=too long
	FTRAP&cc.L	#$53815381	;EXECUTE. $5381=subq.l #1,d1. -2=too short. -1=too short
	subq.l	#1,d1			;actual result upper. 0=ok
	subq.l	#1,d1			;actual result upper. 1=too long
	subq.l	#1,d1			;actual result upper. 2=too long
	rts
  .endm
	.cpu	68000

	.align	4
ftrapccl060_expected_compressed::
");
  push_start();
  for(mzin=0,15,
      m=bitand(mzin>>3,1);
      z=bitand(mzin>>2,1);
      n=bitand(mzin>>0,1);
      a=[
        0,           \\000000  F
        z,           \\000001  EQ
        !(n||z||m),  \\000010  OGT
        z||!(n||m),  \\000011  OGE
        m&&!(n||z),  \\000100  OLT
        z||(m&&!n),  \\000101  OLE
        !(n||z),     \\000110  OGL
        !n,          \\000111  OR
        n,           \\001000  UN
        n||z,        \\001001  UEQ
        n||!(m||z),  \\001010  UGT
        n||(z||!m),  \\001011  UGE
        n||(m&&!z),  \\001100  ULT
        n||z||m,     \\001101  ULE
        !z,          \\001110  NE
        1            \\001111  T
        ];
      for(cc=0,15,
          push(4,0);
          push(4,a[1+cc]);
          push(4,mzin<<24));
      for(cc=16,31,
          push(4,0);
          push(4,a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0))));
  push_end()
  }
make_ftrapccl88x()={
  my(m,z,n,a);
  print("making ftrapccl88x");
  asm(
"
;--------------------------------------------------------------------------------
;	FTRAPcc.L #<data>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
ftrapccl88x_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040,-(sp)
	peamsg	'FTRAPCC.L #<DATA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FTRAPcc.L #<data>',13,10
;------------------------------------------------
;	d1	actual result upper
;	d2	actual result lower
;	d3	actual status
;	d5	cc=0..31
;	d6	fpsr=(mzin=0..15)<<24
;	d7	0=failed,1=successful
;	a0	expected result upper,expected result lower,expected status,...
;	a1	expected result upper
;	a2	expected result lower
;	a3	expected status
;------------------------------------------------
	lea.l	push_decompressed,a0	;expected result upper,expected result lower,expected status,...
;decompress data
	move.l	a0,-(sp)
	pea.l	ftrapccl88x_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
	move.l	#0<<24,d6		;fpsr=(mzin=0..15)<<24
66:
	moveq.l	#0,d5			;cc=0..31
55:
;FTRAPcc.L #<data>
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	clr.l	trapv_occurred		;actual result lower
	jsr	([ftrapccl88x_execute,za0,d5.l*4])	;EXECUTE
					;actual result upper
	move.l	trapv_occurred,d2	;actual result lower
	fmove.l	fpsr,d3			;actual status
;
	movem.l	(a0),a1-a3		;expected result upper,expected result lower,expected status
;
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	test_double
	lea.l	24(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FTRAP'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	'.L #<data> @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	output_double
	lea.l	28(sp),sp
@@:
;
	lea.l	(12,a0),a0		;expected result upper,expected result lower,expected status,...
;
	addq.w	#1,d5			;cc++
	cmp.w	#31,d5			;cc=0..31
	bls	55b
;
	add.l	#1<<24,d6		;mzin++
	cmp.l	#15<<24,d6		;fpsr=(mzin=0..15)<<24
	bls	66b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
ftrapccl88x_execute::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	ftrapccl88x_execute_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
ftrapccl88x_execute_&cc::
	moveq.l	#3,d1			;actual result upper. 3=too long
	FTRAP&cc.L	#$53815381	;EXECUTE. $5381=subq.l #1,d1. -2=too short. -1=too short
	subq.l	#1,d1			;actual result upper. 0=ok
	subq.l	#1,d1			;actual result upper. 1=too long
	subq.l	#1,d1			;actual result upper. 2=too long
	rts
  .endm
	.cpu	68000

	.align	4
ftrapccl88x_expected_compressed::
");
  push_start();
  for(mzin=0,15,
      m=bitand(mzin>>3,1);
      z=bitand(mzin>>2,1);
      n=bitand(mzin>>0,1);
      a=[
        0,           \\000000  F
        z,           \\000001  EQ
        !(n||z||m),  \\000010  OGT
        z||!(n||m),  \\000011  OGE
        m&&!(n||z),  \\000100  OLT
        z||(m&&!n),  \\000101  OLE
        !(n||z),     \\000110  OGL
        z||!n,       \\000111  OR
        n,           \\001000  UN
        n||z,        \\001001  UEQ
        n||!(m||z),  \\001010  UGT
        n||(z||!m),  \\001011  UGE
        n||(m&&!z),  \\001100  ULT
        n||z||m,     \\001101  ULE
        n||!z,       \\001110  NE
        1            \\001111  T
        ];
      for(cc=0,15,
          push(4,0);
          push(4,a[1+cc]);
          push(4,mzin<<24));
      for(cc=16,31,
          push(4,0);
          push(4,a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0))));
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FTRAPcc.W #<data>
\\----------------------------------------------------------------------------------------
make_ftrapccw060()={
  my(m,z,n,a);
  print("making ftrapccw060");
  asm(
"
;--------------------------------------------------------------------------------
;	FTRAPcc.W #<data>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
ftrapccw060_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#FPSP060,-(sp)
	peamsg	'FTRAPCC.W #<DATA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FTRAPcc.W #<data>',13,10
;------------------------------------------------
;	d1	actual result upper
;	d2	actual result lower
;	d3	actual status
;	d5	cc=0..31
;	d6	fpsr=(mzin=0..15)<<24
;	d7	0=failed,1=successful
;	a0	expected result upper,expected result lower,expected status,...
;	a1	expected result upper
;	a2	expected result lower
;	a3	expected status
;------------------------------------------------
	lea.l	push_decompressed,a0	;expected result upper,expected result lower,expected status,...
;decompress data
	move.l	a0,-(sp)
	pea.l	ftrapccw060_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
	move.l	#0<<24,d6		;fpsr=(mzin=0..15)<<24
66:
	moveq.l	#0,d5			;cc=0..31
55:
;FTRAPcc.W #<data>
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	clr.l	trapv_occurred		;actual result upper
	jsr	([ftrapccw060_execute,za0,d5.l*4])	;EXECUTE
					;actual result lower
	move.l	trapv_occurred,d2	;actual result upper
	fmove.l	fpsr,d3			;actual status
;
	movem.l	(a0),a1-a3		;expected result upper,expected result lower,expected status
;
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	test_double
	lea.l	24(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FTRAP'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	'.W #<data> @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	output_double
	lea.l	28(sp),sp
@@:
;
	lea.l	(12,a0),a0		;expected result upper,expected result lower,expected status,...
;
	addq.w	#1,d5			;cc++
	cmp.w	#31,d5			;cc=0..31
	bls	55b
;
	add.l	#1<<24,d6		;mzin++
	cmp.l	#15<<24,d6		;fpsr=(mzin=0..15)<<24
	bls	66b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
ftrapccw060_execute::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	ftrapccw060_execute_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
ftrapccw060_execute_&cc::
	moveq.l	#3,d1			;actual result upper. 3=too long
	FTRAP&cc.W	#$5381		;EXECUTE. $5381=subq.l #1,d1. -1=too short
	subq.l	#1,d1			;actual result upper. 0=ok
	subq.l	#1,d1			;actual result upper. 1=too long
	subq.l	#1,d1			;actual result upper. 2=too long
	rts
  .endm
	.cpu	68000

	.align	4
ftrapccw060_expected_compressed::
");
  push_start();
  for(mzin=0,15,
      m=bitand(mzin>>3,1);
      z=bitand(mzin>>2,1);
      n=bitand(mzin>>0,1);
      a=[
        0,           \\000000  F
        z,           \\000001  EQ
        !(n||z||m),  \\000010  OGT
        z||!(n||m),  \\000011  OGE
        m&&!(n||z),  \\000100  OLT
        z||(m&&!n),  \\000101  OLE
        !(n||z),     \\000110  OGL
        !n,          \\000111  OR
        n,           \\001000  UN
        n||z,        \\001001  UEQ
        n||!(m||z),  \\001010  UGT
        n||(z||!m),  \\001011  UGE
        n||(m&&!z),  \\001100  ULT
        n||z||m,     \\001101  ULE
        !z,          \\001110  NE
        1            \\001111  T
        ];
      for(cc=0,15,
          push(4,0);
          push(4,a[1+cc]);
          push(4,mzin<<24));
      for(cc=16,31,
          push(4,0);
          push(4,a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0))));
  push_end()
  }
make_ftrapccw88x()={
  my(m,z,n,a);
  print("making ftrapccw88x");
  asm(
"
;--------------------------------------------------------------------------------
;	FTRAPcc.W #<data>
;--------------------------------------------------------------------------------
	.cpu	68030
regs		reg	d0-d7/a0-a5
cregs		reg	fpcr/fpsr/fpiar
fregs		reg	fp0-fp7
	.offsym	0,_a6
_size:
_regs:	.ds.b	.sizeof.(regs)
_fregs:	.ds.b	.sizeof.(fregs)
_cregs:	.ds.b	.sizeof.(cregs)
_a6:	.ds.l	1
_pc:	.ds.l	1
	.text
	.even
ftrapccw88x_test::
	link.w	a6,#_size
	movem.l	regs,(_regs,a6)
	fmovem.l	cregs,(_cregs,a6)
	fmovem.x	fregs,(_fregs,a6)
;
	move.l	#MC68881+MC68882+MC68040+FPSP040,-(sp)
	peamsg	'FTRAPCC.W #<DATA>'
	jbsr	mnemonic_start
	addq.l	#8,sp
	beq	99f
	putmsg	'test: FTRAPcc.W #<data>',13,10
;------------------------------------------------
;	d1	actual result upper
;	d2	actual result lower
;	d3	actual status
;	d5	cc=0..31
;	d6	fpsr=(mzin=0..15)<<24
;	d7	0=failed,1=successful
;	a0	expected result upper,expected result lower,expected status,...
;	a1	expected result upper
;	a2	expected result lower
;	a3	expected status
;------------------------------------------------
	lea.l	push_decompressed,a0	;expected result upper,expected result lower,expected status,...
;decompress data
	move.l	a0,-(sp)
	pea.l	ftrapccw88x_expected_compressed
	jbsr	decompress
	addq.l	#8,sp
	move.l	#0<<24,d6		;fpsr=(mzin=0..15)<<24
66:
	moveq.l	#0,d5			;cc=0..31
55:
;FTRAPcc.W #<data>
	fmove.l	#0,fpcr
	fmove.l	d6,fpsr			;fpsr
	clr.l	trapv_occurred		;actual result lower
	jsr	([ftrapccw88x_execute,za0,d5.l*4])	;EXECUTE
					;actual result upper
	move.l	trapv_occurred,d2	;actual result lower
	fmove.l	fpsr,d3			;actual status
;
	movem.l	(a0),a1-a3		;expected result upper,expected result lower,expected status
;
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	test_double
	lea.l	24(sp),sp
	move.l	d0,d7			;0=failed,1=successful
;
	move.l	d7,-(sp)		;0=failed,1=successful
	jbsr	statistics_update
	addq.l	#4,sp
	beq	@f			;not output
;output
	putmsg	'FTRAP'
	putstr	(uppercase_cc,za0,d5.l*4)
	putmsg	'.W #<data> @'
	move.l	d6,-(sp)		;fpsr
	jbsr	printfpsr
	addq.l	#4,sp
	putcrlf
	move.l	d7,-(sp)		;0=failed,1=successful
	movem.l	d1-d3/a1-a3,-(sp)	;actual result upper,actual result lower,actual status,expected result upper,expected result lower,expected status
	jbsr	output_double
	lea.l	28(sp),sp
@@:
;
	lea.l	(12,a0),a0		;expected result upper,expected result lower,expected status,...
;
	addq.w	#1,d5			;cc++
	cmp.w	#31,d5			;cc=0..31
	bls	55b
;
	add.l	#1<<24,d6		;mzin++
	cmp.l	#15<<24,d6		;fpsr=(mzin=0..15)<<24
	bls	66b
;
	jbsr	mnemonic_end
99:
	fmovem.x	(_fregs,a6),fregs
	fmovem.l	(_cregs,a6),cregs
	movem.l	(_regs,a6),regs
	unlk	a6
	rts

	.align	4
ftrapccw88x_execute::
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
	.dc.l	ftrapccw88x_execute_&cc
  .endm
  .irp cc,F,EQ,OGT,OGE,OLT,OLE,OGL,OR,UN,UEQ,UGT,UGE,ULT,ULE,NE,T,SF,SEQ,GT,GE,LT,LE,GL,GLE,NGLE,NGL,NLE,NLT,NGE,NGT,SNE,ST
ftrapccw88x_execute_&cc::
	moveq.l	#3,d1			;actual result upper. 3=too long
	FTRAP&cc.W	#$5381		;EXECUTE. $5381=subq.l #1,d1. -1=too short
	subq.l	#1,d1			;actual result upper. 0=ok
	subq.l	#1,d1			;actual result upper. 1=too long
	subq.l	#1,d1			;actual result upper. 2=too long
	rts
  .endm
	.cpu	68000

	.align	4
ftrapccw88x_expected_compressed::
");
  push_start();
  for(mzin=0,15,
      m=bitand(mzin>>3,1);
      z=bitand(mzin>>2,1);
      n=bitand(mzin>>0,1);
      a=[
        0,           \\000000  F
        z,           \\000001  EQ
        !(n||z||m),  \\000010  OGT
        z||!(n||m),  \\000011  OGE
        m&&!(n||z),  \\000100  OLT
        z||(m&&!n),  \\000101  OLE
        !(n||z),     \\000110  OGL
        z||!n,       \\000111  OR
        n,           \\001000  UN
        n||z,        \\001001  UEQ
        n||!(m||z),  \\001010  UGT
        n||(z||!m),  \\001011  UGE
        n||(m&&!z),  \\001100  ULT
        n||z||m,     \\001101  ULE
        n||!z,       \\001110  NE
        1            \\001111  T
        ];
      for(cc=0,15,
          push(4,0);
          push(4,a[1+cc]);
          push(4,mzin<<24));
      for(cc=16,31,
          push(4,0);
          push(4,a[1+cc-16]);
          push(4,(mzin<<24)+if(n,BS+AV,0))));
  push_end()
  }


\\----------------------------------------------------------------------------------------
\\  FTST.X FPm,FPn
\\----------------------------------------------------------------------------------------
ftst_func(x,rp,rm)={
  fpsr=bitor(fpsr,if(x==-Inf,MI+IN,
                     x==-Rei,MI+ZE,
                     x==Rei,ZE,
                     x==Inf,IN,
                     x==NaN,NA,
                     x<0,MI,
                     0))
  }
make_ftst()={
  make_fop1to0("ftst",
               "ftst",
               -1,
               MC68881+MC68882+MC68040+FPSP040+MC68060+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND),
               ftst_func)
  }


\\----------------------------------------------------------------------------------------
\\  FTWOTOX.X FPm,FPn
\\----------------------------------------------------------------------------------------
make_ftwotox()={
  make_fop1to1("ftwotox",
               "ftwotox",
               -2,
               MC68881+MC68882+FPSP040+FPSP060,
               append(DATA_SPECIAL,
                      DATA_FLOAT,
                      DATA_BASIC,
                      DATA_ROUND,
                      DATA_ZERO_PLUS),
               (x,rp,rm)->if(type(x)=="t_POL",
                             if(x==-Inf,Rei,  \\twotox(-Inf)=+0
                                x==-Rei,1,  \\twotox(-0)=1
                                x==Rei,1,  \\twotox(+0)=1
                                x==Inf,Inf,  \\twotox(+Inf)=+Inf
                                NaN),
                             fpsr=bitor(fpsr,X2);
                             if(x<=-65536,fpsr=bitor(fpsr,UF);xxx(Rei,rp,rm),  \\twotox(-big)=+0,UF
                                65536<x,fpsr=bitor(fpsr,OF);xxx(Inf,rp,rm),  \\twotox(+big)=+Inf,OF
                                xxx(2^x,rp,rm))))
  }



1;
1 2