#include	<stdio.h>
#include	<memory.h>
#include	<strings.h>

FILE	*fpw;

main()
{
	static char	filename[] = {"pars.DAT"};
	static char	cpcom1[] = {"cp "};
	static char	cpcom2[] = {" ../asm/"};
	char	c[125];

	if(( fpw = fopen(filename,"w")) == NULL){
		printf("Write file open error !!\n");
		exit(1);
	}

	data_0();

	fclose(fpw);

/**************************/
	strcpy(c,cpcom1);
	strcat(c,filename);
	strcat(c, cpcom2);
	strcat(c,filename);
	printf("\n%s\n",c);
	system(c);
/**************************/
}

data_0()
{
	int	i;
	double	a, b, c, d, e, f, L, L2;

	fprintf(fpw,"PARSDT\t\tEQU\t$");

	a = 1.0 / (2048.0 / 65536.0);	/* 800H */
	b = 1.0 / (224.0 / 65536.0);	/* E0H */
	c = b - a;
	d = c / (double)0x70;

	e = 256.0 / ( 1.0 / a * 65536.0 );
	f = 256.0 / ( 1.0 / b * 65536.0 );

	L  = ( (double)0x70 / ( f - e ) );
	L2 = f * L;
	for(i=0;i<0x70;i++,a+=d){
		e = 1 / a;
		if((i&0x7)==0){
			fprintf(fpw,"\n\t\tWORD\t%05XH",(short)(e * 65536.0));
		}
		else{
			fprintf(fpw,",%05XH",(short)(e * 65536.0));
		}
	}

	fprintf(fpw,"\n;\nPARSMX\t\tEQU\t%05XH",(short)c);
	fprintf(fpw,"\nPARSYP\t\tEQU\t%05XH",(short)(((double)0x70) / f));
	fprintf(fpw,"\nPARSDV\t\tEQU\t$");

	for(a=0.0;a<c;a++){
		e = L2 / ( L + a );
		if((((int)a)&0x3)==0){
			fprintf(fpw,"\n\tWORD\t%04XH,%04XH",(short)(e * 256.0),(short)(1.0 / e * 256.0));
		}
		else{
			fprintf(fpw,",%04XH,%04XH",(short)(e * 256.0),(short)(1.0 / e * 256.0));
		}
	}
	fprintf(fpw,"\n;\n");

}

