
 // Compiler.cpp
 // (c) Сеpгей Гоцуляк, ВВТ-307
 // 26.11.1999 - 10.01.2000

 // Модуль компилятора, который запускается из командной строки.
 // Все пояснения - в документации.

 #include <conio.h>
 #include <stdio.h>
 #include <string.h>
 #include <process.h>
 #include <stdlib.h>
 #include "c:\work\ml307\sources\sets.h"
 #include "c:\work\ml307\sources\NewTI.h"H
 #include "c:\work\ml307\sources\win.h"
 #include <dos.h>

 FILE *file1,*file2,*file3;
 int LexAmount,
	  LexN[500],LexZ[500],
	  ConstAmount,
	  Const[20],
	  IdentAmount,
	  Ident[20],
	  EntryPoint=0x0B6D,
	  ConstantOffset=0x010A,
	  IdentOffset=0x0132,
	  CurLex=0;

 unsigned char CodeBuf[30000];
 unsigned int CodeBufPointer=0,
				  Counter=0;

 void z01();
 void z02();
 void z03(int);
 void z04();
 void z05(unsigned int&);
 void z06(unsigned int&);
 void z07(unsigned int,unsigned int);
 void z08(unsigned int&,unsigned int);
 void z09(unsigned int);
 void z10(unsigned int);
 void z11(int);
 void z12(int);
 void z13();
 void z14(int);
 void z15(int);
 void z16(int&);
 void z17();

 void L_PROG();
 void S_PROG();
 void E_PROG();
 void T_PROG();
 void P_PROG();
 void B_PROG();

 void z01()
 {
	 CodeBuf[CodeBufPointer]=0xB4;
	 CodeBuf[CodeBufPointer+1]=0x4C;
	 CodeBuf[CodeBufPointer+2]=0xCD;
	 CodeBuf[CodeBufPointer+3]=0x21;
	 CodeBufPointer=CodeBufPointer+4;
	 Counter+=4;
 }

 void z02(int s)
 {
	 if(s==0)
	 {
		 CodeBuf[CodeBufPointer]=0x5B;
		 CodeBuf[CodeBufPointer+1]=0x58;
		 CodeBuf[CodeBufPointer+2]=0x3B;
		 CodeBuf[CodeBufPointer+3]=0xC3;
		 CodeBuf[CodeBufPointer+4]=0x74;
		 CodeBuf[CodeBufPointer+5]=0x06;
		 CodeBuf[CodeBufPointer+6]=0xB8;
		 CodeBuf[CodeBufPointer+7]=0x01;
		 CodeBuf[CodeBufPointer+8]=0x00;
		 CodeBuf[CodeBufPointer+9]=0xEB;
		 CodeBuf[CodeBufPointer+10]=0x04;
		 CodeBuf[CodeBufPointer+11]=0x90;
		 CodeBuf[CodeBufPointer+12]=0xB8;
		 CodeBuf[CodeBufPointer+13]=0x00;
		 CodeBuf[CodeBufPointer+14]=0x00;
		 CodeBuf[CodeBufPointer+15]=0x50;

		 CodeBufPointer=CodeBufPointer+16;
		 Counter+=16;
	 }
	 if(s==1)
	 {
		 CodeBuf[CodeBufPointer]=0x5B;
		 CodeBuf[CodeBufPointer+1]=0x58;
		 CodeBuf[CodeBufPointer+2]=0x3B;
		 CodeBuf[CodeBufPointer+3]=0xC3;
		 CodeBuf[CodeBufPointer+4]=0x75;
		 CodeBuf[CodeBufPointer+5]=0x06;
		 CodeBuf[CodeBufPointer+6]=0xB8;
		 CodeBuf[CodeBufPointer+7]=0x01;
		 CodeBuf[CodeBufPointer+8]=0x00;
		 CodeBuf[CodeBufPointer+9]=0xEB;
		 CodeBuf[CodeBufPointer+10]=0x04;
		 CodeBuf[CodeBufPointer+11]=0x90;
		 CodeBuf[CodeBufPointer+12]=0xB8;
		 CodeBuf[CodeBufPointer+13]=0x00;
		 CodeBuf[CodeBufPointer+14]=0x00;
		 CodeBuf[CodeBufPointer+15]=0x50;
		 CodeBufPointer=CodeBufPointer+16;
		 Counter+=16;
	 }
	 if(s==2)
	 {
		 CodeBuf[CodeBufPointer]=0x5B;
		 CodeBuf[CodeBufPointer+1]=0x58;
		 CodeBuf[CodeBufPointer+2]=0x3B;
		 CodeBuf[CodeBufPointer+3]=0xC3;
		 CodeBuf[CodeBufPointer+4]=0x7F;
		 CodeBuf[CodeBufPointer+5]=0x06;
		 CodeBuf[CodeBufPointer+6]=0xB8;
		 CodeBuf[CodeBufPointer+7]=0x01;
		 CodeBuf[CodeBufPointer+8]=0x00;
		 CodeBuf[CodeBufPointer+9]=0xEB;
		 CodeBuf[CodeBufPointer+10]=0x04;
		 CodeBuf[CodeBufPointer+11]=0x90;
		 CodeBuf[CodeBufPointer+12]=0xB8;
		 CodeBuf[CodeBufPointer+13]=0x00;
		 CodeBuf[CodeBufPointer+14]=0x00;
		 CodeBuf[CodeBufPointer+15]=0x50;
		 CodeBufPointer=CodeBufPointer+16;
		 Counter+=16;
	 }
	 if(s==3)
	 {
		 CodeBuf[CodeBufPointer]=0x5B;
		 CodeBuf[CodeBufPointer+1]=0x58;
		 CodeBuf[CodeBufPointer+2]=0x3B;
		 CodeBuf[CodeBufPointer+3]=0xC3;
		 CodeBuf[CodeBufPointer+4]=0x7C;
		 CodeBuf[CodeBufPointer+5]=0x06;
		 CodeBuf[CodeBufPointer+6]=0xB8;
		 CodeBuf[CodeBufPointer+7]=0x01;
		 CodeBuf[CodeBufPointer+8]=0x00;
		 CodeBuf[CodeBufPointer+9]=0xEB;
		 CodeBuf[CodeBufPointer+10]=0x04;
		 CodeBuf[CodeBufPointer+11]=0x90;
		 CodeBuf[CodeBufPointer+12]=0xB8;
		 CodeBuf[CodeBufPointer+13]=0x00;
		 CodeBuf[CodeBufPointer+14]=0x00;
		 CodeBuf[CodeBufPointer+15]=0x50;
		 CodeBufPointer=CodeBufPointer+16;
		 Counter+=16;
	 }
	 if(s==4)
	 {
		 CodeBuf[CodeBufPointer]=0x5B;
		 CodeBuf[CodeBufPointer+1]=0x58;
		 CodeBuf[CodeBufPointer+2]=0x3B;
		 CodeBuf[CodeBufPointer+3]=0xC3;
		 CodeBuf[CodeBufPointer+4]=0x7D;
		 CodeBuf[CodeBufPointer+5]=0x06;
		 CodeBuf[CodeBufPointer+6]=0xB8;
		 CodeBuf[CodeBufPointer+7]=0x01;
		 CodeBuf[CodeBufPointer+8]=0x00;
		 CodeBuf[CodeBufPointer+9]=0xEB;
		 CodeBuf[CodeBufPointer+10]=0x04;
		 CodeBuf[CodeBufPointer+11]=0x90;
		 CodeBuf[CodeBufPointer+12]=0xB8;
		 CodeBuf[CodeBufPointer+13]=0x00;
		 CodeBuf[CodeBufPointer+14]=0x00;
		 CodeBuf[CodeBufPointer+15]=0x50;
		 CodeBufPointer=CodeBufPointer+16;
		 Counter+=16;
	 }
	 if(s==5)
	 {
		 CodeBuf[CodeBufPointer]=0x5B;
		 CodeBuf[CodeBufPointer+1]=0x58;
		 CodeBuf[CodeBufPointer+2]=0x3B;
		 CodeBuf[CodeBufPointer+3]=0xC3;
		 CodeBuf[CodeBufPointer+4]=0x7E;
		 CodeBuf[CodeBufPointer+5]=0x06;
		 CodeBuf[CodeBufPointer+6]=0xB8;
		 CodeBuf[CodeBufPointer+7]=0x01;
		 CodeBuf[CodeBufPointer+8]=0x00;
		 CodeBuf[CodeBufPointer+9]=0xEB;
		 CodeBuf[CodeBufPointer+10]=0x04;
		 CodeBuf[CodeBufPointer+11]=0x90;
		 CodeBuf[CodeBufPointer+12]=0xB8;
		 CodeBuf[CodeBufPointer+13]=0x00;
		 CodeBuf[CodeBufPointer+14]=0x00;
		 CodeBuf[CodeBufPointer+15]=0x50;
		 CodeBufPointer=CodeBufPointer+16;
		 Counter+=16;
	 }
 }

 void z03(int k)
 {
	 CodeBuf[CodeBufPointer]=0x58;
	 CodeBuf[CodeBufPointer+1]=0xBB;
	 CodeBuf[CodeBufPointer+2]=0x32;
	 CodeBuf[CodeBufPointer+3]=0x01;
	 CodeBuf[CodeBufPointer+4]=0x83;
	 CodeBuf[CodeBufPointer+5]=0xC3;
	 CodeBuf[CodeBufPointer+6]=k*2;
	 CodeBuf[CodeBufPointer+7]=0x89;
	 CodeBuf[CodeBufPointer+8]=0x07;
	 CodeBufPointer=CodeBufPointer+9;
	 Counter+=9;
 }

 void z04()
 {
	 CodeBuf[CodeBufPointer]=0x58;
	 CodeBuf[CodeBufPointer+1]=0xE8;
	 //unsigned int ProcOutNumOffset;
	 //unsigned char HighByte,LowByte;
	 //ProcOutNumOffset=0xFDFA-(Counter-EntryPoint)-2;
         int ProcOutNumOffset;
	 unsigned char HighByte,LowByte;
	 ProcOutNumOffset=-(Counter-0x0969)-4;
	 _asm {
		 mov	ax,ProcOutNumOffset
		 mov	HighByte,ah
		 mov	LowByte,al
	 };
	 CodeBuf[CodeBufPointer+2]=LowByte;
	 CodeBuf[CodeBufPointer+3]=HighByte;
	 CodeBufPointer=CodeBufPointer+4;
	 Counter+=4;
 }

 void z05(unsigned int &n)
 {
	 n=Counter;
 }

 void z06(unsigned int &m)
 {
	 m=Counter;
	 CodeBuf[CodeBufPointer]=0x58;
	 CodeBuf[CodeBufPointer+1]=0x3D;
	 CodeBuf[CodeBufPointer+2]=0x01;
	 CodeBuf[CodeBufPointer+3]=0x00;
	 CodeBuf[CodeBufPointer+4]=0x75;
	 CodeBuf[CodeBufPointer+5]=0x03;
	 CodeBuf[CodeBufPointer+6]=0xE9;
	 unsigned int JumpOffset;
	 unsigned char HighByte,LowByte;
	 JumpOffset=0x0000;
	 _asm {
		 mov	ax,JumpOffset
		 mov	HighByte,ah
		 mov	LowByte,al
	 };
	 CodeBuf[CodeBufPointer+7]=LowByte;
	 CodeBuf[CodeBufPointer+8]=HighByte;
	 CodeBufPointer=CodeBufPointer+9;
	 Counter+=9;
 }

 void z07(unsigned int n, unsigned int m)
 {
	 CodeBuf[CodeBufPointer]=0xE9;
	 unsigned int JumpOffset;
	 int JumpOffset2;
	 unsigned char HighByte,LowByte;
	 JumpOffset2=-(Counter-n)-3;
	 _asm {
		 mov	ax,JumpOffset2
		 mov	HighByte,ah
		 mov	LowByte,al
	 };
	 CodeBuf[CodeBufPointer+1]=LowByte;
	 CodeBuf[CodeBufPointer+2]=HighByte;
	 CodeBufPointer=CodeBufPointer+3;
	 Counter+=3;
	 JumpOffset=Counter-m-9;
	 _asm {
		 mov	ax,JumpOffset
		 mov	HighByte,ah
		 mov	LowByte,al
	 };
	 CodeBuf[m-EntryPoint+7]=LowByte;
	 CodeBuf[m-EntryPoint+7+1]=HighByte;
 }

 void z08(unsigned int &n, unsigned int m)
 {
	 n=Counter;
	 CodeBuf[CodeBufPointer]=0xE9;
	 int JumpOffset;
	 unsigned char HighByte,LowByte;
	 JumpOffset=0;
	 _asm {
		 mov	ax,JumpOffset
		 mov	HighByte,ah
		 mov	LowByte,al
	 };
	 CodeBuf[CodeBufPointer+1]=LowByte;
	 CodeBuf[CodeBufPointer+2]=HighByte;
	 CodeBufPointer=CodeBufPointer+3;
	 Counter+=3;
	 JumpOffset=Counter-m-9;
	 _asm {
		 mov	ax,JumpOffset
		 mov	HighByte,ah
		 mov	LowByte,al
	 };
	 CodeBuf[m-EntryPoint+7]=LowByte;
	 CodeBuf[m-EntryPoint+7+1]=HighByte;
 }

 void z09(unsigned int n)
 {
	 int JumpOffset;
	 unsigned char HighByte,LowByte;
	 JumpOffset=Counter-n-3;
	 _asm {
		 mov	ax,JumpOffset
		 mov	HighByte,ah
		 mov	LowByte,al
	 };
	 CodeBuf[n-EntryPoint+1]=LowByte;
	 CodeBuf[n-EntryPoint+2]=HighByte;
 }

 void z10(unsigned int m)
 {
	 int JumpOffset;
	 unsigned char HighByte,LowByte;
	 JumpOffset=Counter-m-9;
	 _asm {
		 mov	ax,JumpOffset
		 mov	HighByte,ah
		 mov	LowByte,al
	 };
	 CodeBuf[m-EntryPoint+7]=LowByte;
	 CodeBuf[m-EntryPoint+8]=HighByte;
 }

 void z11(int k)
 {
	 CodeBuf[CodeBufPointer]=0xBB;
	 CodeBuf[CodeBufPointer+1]=0x32;
	 CodeBuf[CodeBufPointer+2]=0x01;
	 CodeBuf[CodeBufPointer+3]=0x83;
	 CodeBuf[CodeBufPointer+4]=0xC3;
	 CodeBuf[CodeBufPointer+5]=k*2;
	 CodeBuf[CodeBufPointer+6]=0x8B;
	 CodeBuf[CodeBufPointer+7]=0x07;
	 CodeBuf[CodeBufPointer+8]=0x50;
	 CodeBufPointer=CodeBufPointer+9;
	 Counter+=9;
 }

 void z12(int k)
 {
	 CodeBuf[CodeBufPointer]=0xBB;
	 CodeBuf[CodeBufPointer+1]=0x0A;
	 CodeBuf[CodeBufPointer+2]=0x01;
	 CodeBuf[CodeBufPointer+3]=0x83;
	 CodeBuf[CodeBufPointer+4]=0xC3;
	 CodeBuf[CodeBufPointer+5]=k*2;
	 CodeBuf[CodeBufPointer+6]=0x8B;
	 CodeBuf[CodeBufPointer+7]=0x07;
	 CodeBuf[CodeBufPointer+8]=0x50;
	 CodeBufPointer=CodeBufPointer+9;
	 Counter+=9;
 }

 void z13()
 {
	 CodeBuf[CodeBufPointer]=0xE8;
	 //unsigned int ProcInIntOffset;
	 //unsigned char HighByte,LowByte;
	 //ProcInIntOffset=0xFF4A-(Counter-EntryPoint)-1;
         int ProcInIntOffset;
	 unsigned char HighByte,LowByte;
	 ProcInIntOffset=-(Counter-0x0AB9)-3;

	 _asm {
		 mov	ax,ProcInIntOffset
		 mov	HighByte,ah
		 mov	LowByte,al
	 };
	 CodeBuf[CodeBufPointer+1]=LowByte;
	 CodeBuf[CodeBufPointer+2]=HighByte;
	 CodeBuf[CodeBufPointer+3]=0x50;
	 CodeBufPointer=CodeBufPointer+4;
	 Counter+=4;
 }

 void z14(int k)
 {
	 if(k==0)
	 {
		 CodeBuf[CodeBufPointer]=0x5B;
		 CodeBuf[CodeBufPointer+1]=0x58;
		 CodeBuf[CodeBufPointer+2]=0x99;
		 CodeBuf[CodeBufPointer+3]=0xF7;
		 CodeBuf[CodeBufPointer+4]=0xE3;
		 CodeBuf[CodeBufPointer+5]=0x50;
		 CodeBufPointer=CodeBufPointer+6;
		 Counter+=6;
	 }
	 else
	 {

		 CodeBuf[CodeBufPointer]=0x5B;
		 CodeBuf[CodeBufPointer+1]=0x58;
		 CodeBuf[CodeBufPointer+2]=0x99;
		 CodeBuf[CodeBufPointer+3]=0xF7;
		 CodeBuf[CodeBufPointer+4]=0xF3;
		 CodeBuf[CodeBufPointer+5]=0x50;
		 CodeBufPointer=CodeBufPointer+6;
		 Counter+=6;
	 }
 }

 void z15(int k)
 {
	 if(k==0)
	 {
		 CodeBuf[CodeBufPointer]=0x58;
		 CodeBuf[CodeBufPointer+1]=0x5B;
		 CodeBuf[CodeBufPointer+2]=0x03;
		 CodeBuf[CodeBufPointer+3]=0xC3;
		 CodeBuf[CodeBufPointer+4]=0x50;
		 CodeBufPointer=CodeBufPointer+5;
		 Counter+=5;
	 }
	 else
	 {
		 CodeBuf[CodeBufPointer]=0x58;
		 CodeBuf[CodeBufPointer+1]=0x5B;
		 CodeBuf[CodeBufPointer+2]=0x2B;
		 CodeBuf[CodeBufPointer+3]=0xD8;
		 CodeBuf[CodeBufPointer+4]=0x53;
		 CodeBufPointer=CodeBufPointer+5;
		 Counter+=5;
	 }
 }

 void z16(int &k)
 {
	 k=0;
 }

 void z17(int k)
 {
	 if(k==1)
	 {
		 CodeBuf[CodeBufPointer]=0x58;
		 CodeBuf[CodeBufPointer+1]=0xF7;
		 CodeBuf[CodeBufPointer+2]=0xD8;
		 CodeBuf[CodeBufPointer+3]=0x50;
		 CodeBufPointer=CodeBufPointer+4;
		 Counter+=4;
	 }
 }

 void L_PROG()
 {
	 while(1)
	 {
		 S_PROG();
		 if(CurLex>=(LexAmount-1)||
			 (LexN[CurLex]==3||
			  LexN[CurLex]==5||
			  LexN[CurLex]==7)&&
			  LexN[CurLex]!=12)
			  break;
		 if(LexN[CurLex]!=12)
			 exit(505);
		 CurLex++;
	 }
 }

 void S_PROG()
 {
	 if(LexN[CurLex]==19)      // идентификатор
	 {
		 int k=LexZ[CurLex];
		 if(LexN[++CurLex]!=16)
			 exit(506);
		 CurLex++;
		 E_PROG();
		 z03(k);
	 }
	 if(LexN[CurLex]==8)       // output
	 {
		 CurLex++;
		 if(LexN[CurLex]!=17)
			 exit(507);
		 CurLex++;
		 E_PROG();
		 if(LexN[CurLex]!=18)
			 exit(508);
		 CurLex++;
		 z04();
	 }
	 if(LexN[CurLex]==11)      // while
	 {
		 unsigned int n;
		 z05(n);
		 CurLex++;
		 B_PROG();
		 if(LexN[CurLex]!=2)    // do
			 exit(509);
		 unsigned int m;
		 z06(m);
		 CurLex++;
		 L_PROG();
		 if(LexN[CurLex]!=7)    // od
			 exit(510);
		 z07(n,m);
		 CurLex++;
	 }
	 if(LexN[CurLex]==6)       // if
	 {
		 CurLex++;
		 B_PROG();
		 unsigned int m;
		 z06(m);
		 if(LexN[CurLex]!=10)   // then
			 exit(513);
		 CurLex++;
		 L_PROG();
		 if(LexN[CurLex]==3)    // else
		 {
			 unsigned int n;
			 z08(n,m);
			 CurLex++;
			 L_PROG();
			 if(LexN[CurLex]!=5) // fi
				 exit(514);
			 z09(n);
			 CurLex++;
			 return;
		 }
		 if(LexN[CurLex]!=5) // fi
			 exit(514);
		 z10(m);
		 CurLex++;
	 }
 }

 void E_PROG()
 {
	 int k;
	 if(LexN[CurLex]==14)
	 {
		 k=LexZ[CurLex];
		 CurLex++;
		 T_PROG();
		 z17(k);
	 }
	 else
	 {
		 T_PROG();
		 z16(k);
	 }
	 while(1)
	 {
		 if(LexN[CurLex]==14)
		 {
			 k=LexZ[CurLex];
			 CurLex++;
			 T_PROG();
			 z15(k);
		 }
		 else
			 break;
	 }
 }

 void T_PROG()
 {
	 int k;
	 P_PROG();
	 while(1)
	 {
		 if(LexN[CurLex]==15)
		 {
			 k=LexZ[CurLex];
			 CurLex++;
			 P_PROG();
			 z14(k);
		 }
		 else
			 break;
	 }
 }

 void P_PROG()
 {
	 int k;
	 if(LexN[CurLex]==20)       // константа
	 {
		 k=LexZ[CurLex];
		 CurLex++;
		 z12(k);
		 return;
	 }
	 if(LexN[CurLex]==19)       // идентификатор
	 {
		 k=LexZ[CurLex];
		 CurLex++;
		 z11(k);
		 return;
	 }
	 if(LexN[CurLex]==17)       // открывающая скобка
	 {
		 CurLex++;
		 E_PROG();
		 if(LexN[CurLex]!=18)    // закрывающая скобка
			 exit(511);
		 CurLex++;
	 }
	 if(LexN[CurLex]==9)        // read
	 {
		 z13();
		 CurLex++;
	 }
 }

 void B_PROG()
 {
	 E_PROG();
	 if(LexN[CurLex]!=13)
		 exit(512);
	 int s=LexZ[CurLex];
	 CurLex++;
	 E_PROG();
	 z02(s);
 }

 int main()
 {
    char ComFileName[80];
    file1=fopen("FileName.tmp","rb");
	 if(file1==NULL)
		 exit(201);
    fgets(ComFileName,80,file1);
    fclose(file1);

	 file1=fopen("Phase02.tmp","rb");
	 if(file1==NULL)
		 exit(201);

	 char cons[20][10];
	 fscanf(file1,"%d",&LexAmount);
	 for(int i=0;i<500;i++)
		 fscanf(file1,"%d,%d",&LexN[i],&LexZ[i]);
	 fscanf(file1,"%d",&IdentAmount);
	 fscanf(file1,"%d",&ConstAmount);
	 for(i=0;i<20;i++)
	 {
		 fscanf(file1,"%s",cons[i]);
		 Const[i]=atoi(cons[i]);
	 }
	 fclose(file1);
	 printf("\n    - Число лексем: %3d \n    - ",LexAmount);
	 int t=0;
	 for(i=0;i<LexAmount;i++)
	 {
		 if(t>=10)
		 {
			 t=0;
			 printf("\n    - ");
		 }
		 t=t+1;
		 printf("[%2d,%2d]",LexN[i],LexZ[i]);
	 }
	 printf("\n    - Число идентификаторов: %2d",IdentAmount);
	 printf("\n    - Число констант: %2d",ConstAmount);
	 textcolor(RED);
	 printf("\n\n");
	 cprintf(" Фаза03: ");
	 textcolor(YELLOW);
	 cprintf("Компилятоp ");
	 textcolor(LIGHTBLUE);
	 printf("\n");
	 cprintf("    - Компиляция пpогpаммы ...");

	 //***********************************************************************
	 //*                    Основной модуль                                  *
	 //***********************************************************************

	 Counter=EntryPoint;
	 if(LexN[CurLex]!=1)     // begin
		 exit(501);
	 CurLex++;

	 L_PROG();

	 if(LexN[CurLex]!=4)     // end
		 exit(502);
	 CurLex++;
	 if(LexN[CurLex]!=0)
		 exit(503);
	 z01();

	 // Генерируем com-файл

	 file2=fopen("com.com","rb");
	 if(file2==NULL)
		 exit(504);
	 //file3=fopen("Phase03.com","wb");
         file3=fopen(ComFileName,"wb");
	 while(1)
	 {
		 int sym=fgetc(file2);
		 if(sym==EOF)
			 break;
		 fputc(sym,file3);
	 }
	 fseek(file3,-4,SEEK_END);
	 for(i=0;i<CodeBufPointer;i++)
		 fputc(CodeBuf[i],file3);
	 fseek(file3,0x0A,SEEK_SET);
	 fwrite(&Const,sizeof(Const), 1,file3);
	 fwrite(&Ident,sizeof(Ident), 1,file3);

	 //***********************************************************************
	 //*                    Конец                                            *
	 //***********************************************************************
	 fclose(file2);
	 fclose(file3);
	 exit(0);
	 return 0;
 }