#include "delta_encrier.h"
#include <string.h>

/* table des lexemes */
extern ECHANT *Techant;
extern long nb_echant;

/* table des types de variables */
extern TYPE_VARIABLE tab_type_variable[MAX_TYPE_VARIABLE];
extern int nb_tab_type_variable;


/* table des instructions */
extern INSTRUCTION tab_instruction[MAX_INSTRUCTION];
extern int nb_instruction;

/* table des fonctions */
extern FONCTION tab_fonction[MAX_FONCTION];
extern int nb_fonction;

extern char tab_fonctions_appelees[MAX_FONCTION][MAX_IDENT];
extern int nb_fonctions_appelees;


/* table des routines */
extern SUBROUTINE tab_subroutine[MAX_SUBROUTINE];
extern int nb_subroutine;

/* table des taches */
extern TACHE tab_tache[MAX_TACHE];
extern int nb_tache;

/* table des mutex */
extern TAB_MUTEX tab_mutex[MAX_MUTEX];
extern int nb_mutex;

/* programme */
extern PROGRAM program;

/* fonction de message d'erreur */
extern void message_erreur(char *);

/* trace de generation de code =1 si oui / 0 sinon */
extern int etat_trace2;

extern void monte(void);
extern void descend(void);

FILE *file_code;
extern char affiche[1000];

extern int recherche_type(char *);

/* fonction de recherche de variable */
int recherche_variable(char *,char *);

extern int etat_sema;

/***********************************/
/* table des types non structure   */
/***********************************/

/*static char tab_atome[MAX_IDENT][6]={"byte","sbyte","word","sword","dword","sdword"};*/
char tab_atome[MAX_TYPE_VARIABLE][MAX_IDENT];
int max_tab_atome;
int ind_et=0;
int ind_ou=0;

void init_tab_atome(void)
 {
	 int i,j;
	 int ind;

	 ind=0;

	 strcpy(tab_atome[ind++],"byte");
	 strcpy(tab_atome[ind++],"sbyte");
	 strcpy(tab_atome[ind++],"word");
	 strcpy(tab_atome[ind++],"sword");
	 strcpy(tab_atome[ind++],"dword");
	 strcpy(tab_atome[ind++],"sdword");

	 strcpy(tab_atome[ind++],"byte_tab");
	 strcpy(tab_atome[ind++],"sbyte_tab");
	 strcpy(tab_atome[ind++],"word_tab");
	 strcpy(tab_atome[ind++],"sword_tab");
	 strcpy(tab_atome[ind++],"dword_tab");
	 strcpy(tab_atome[ind++],"sdword_tab");

	 for(i=0;i<nb_tab_type_variable;i++)
	    {
			if(tab_type_variable[i].genre_variable==STRUCTURE)
				{
					strcpy (tab_atome[ind++],tab_type_variable[i].type);
					sprintf(tab_atome[ind++],"%s_tab",tab_type_variable[i].type);
				}
		}

	 max_tab_atome=ind;
 }

/***********************************/
/* gestion pile boucle             */
/***********************************/

INSTRUCTION *pile_boucle[1000];
int sp_boucle=-1;

void push_boucle(INSTRUCTION *v)
 {
	 sp_boucle++;
	 if(sp_boucle==1000)
		 	message_erreur(GC0001);
	 pile_boucle[sp_boucle]=v;
 }

void pop_boucle(void)
 {
	 sp_boucle--;
	 if(sp_boucle<-1)
		 	message_erreur(GC0020);
 }

INSTRUCTION *consulte_boucle(void)
 {
	 if(sp_boucle<0)
		 	message_erreur(GC0030);

	 return(pile_boucle[sp_boucle]);
 }

/* fonction de generation de types */

void genere_types(void)
 {
	 int i,j;

	 for(i=0;i<nb_tab_type_variable;i++)
	    {


			if(tab_type_variable[i].genre_variable==STRUCTURE)
				{
					if(etat_trace2==1) fprintf(file_code,"\n// DECLARATION STRUCTURE %s",tab_type_variable[i].type);
					fprintf(file_code,"\n%s struct",tab_type_variable[i].type);

					for(j=0;j<tab_type_variable[i].nb_champ;j++)
						{
							char type[MAX_IDENT];

							if(strcmp(tab_type_variable[i].type_variable_ptr[j]->type,"float")!=0)
								{
									fprintf(file_code,"\n\t%s ",tab_type_variable[i].type_variable_ptr[j]->champ_structure);

									if(strcmp(tab_type_variable[i].type_variable_ptr[j]->type,"byte")==0)  			fprintf(file_code,"byte");
									else if(strcmp(tab_type_variable[i].type_variable_ptr[j]->type,"char")==0)  	fprintf(file_code,"byte");
									else if(strcmp(tab_type_variable[i].type_variable_ptr[j]->type,"schar")==0) 	fprintf(file_code,"sbyte");
									else if(strcmp(tab_type_variable[i].type_variable_ptr[j]->type,"int")==0)	  	fprintf(file_code,"word");
									else if(strcmp(tab_type_variable[i].type_variable_ptr[j]->type,"sint")==0) 		fprintf(file_code,"sword");
									else if(strcmp(tab_type_variable[i].type_variable_ptr[j]->type,"long")==0)  	fprintf(file_code,"dword");
									else if(strcmp(tab_type_variable[i].type_variable_ptr[j]->type,"slong")==0)		fprintf(file_code,"sdword");
									else fprintf(file_code,"%s",tab_type_variable[i].type_variable_ptr[j]->type);

									if(tab_type_variable[i].type_variable_ptr[j]->nb_dimension>0)
										fprintf(file_code,"[]");
								}
							else fprintf(file_code,"\n// type float non supporté %s %s",
										 tab_type_variable[i].type_variable_ptr[j]->champ_structure,
										 tab_type_variable[i].type_variable_ptr[j]->type);
						}

					fprintf(file_code,"\n%s ends",tab_type_variable[i].type);
				}
		}
 }


/* fonction qui genere le type  */
void genere_type_variable(TYPE_VARIABLE *type,int prof)
	{
		int i;
		char decalage[100];

		strcpy(decalage,"--------------------------------------------------------------------------------------------");
		decalage[prof*3]='\0';

		if(type->genre_variable==ATOME)
			{

				if(strcmp(type->type,"byte")==0)  fprintf(file_code,"byte");
				if(strcmp(type->type,"char")==0)  fprintf(file_code,"byte");
				if(strcmp(type->type,"schar")==0) fprintf(file_code,"sbyte");
				if(strcmp(type->type,"int")==0)	  fprintf(file_code,"word");
				if(strcmp(type->type,"sint")==0)  fprintf(file_code,"sword");
				if(strcmp(type->type,"long")==0)  fprintf(file_code,"dword");
				if(strcmp(type->type,"slong")==0) fprintf(file_code,"sdword");

				/*if(etat_trace2==1)  fprintf(file_code,"\n// %s ATOME ",decalage);
				if(etat_trace2==1)  fprintf(file_code," bloc = %s dimension %d",
											type->bloc,
											type->nb_dimension);

				if(etat_trace2==1)
					fprintf(file_code,"\n//%s type=%s index = %d genre = %d",
						decalage,
						type->type,
						recherche_type(type->type),
						type->genre_variable);*/

				/*if(type->type_pointeur==PASPOINTEUR) { if(traceaff==1) printf(" pas pointeur ");}
				if(type->type_pointeur==POINTEUR) {if(traceaff==1) printf(" * pointeur ");}
				if(type->type_pointeur==POINTEURPOINTEUR) {if(traceaff==1) printf(" ** pointeur ");}*/
			}

		if(type->genre_variable==STRUCTURE)
			{
				if(type->nb_dimension>0)
					{
						if(strcmp(type->type,"byte")==0)  fprintf(file_code,"byte[]");
						else if(strcmp(type->type,"char")==0)  fprintf(file_code,"byte[]");
						else if(strcmp(type->type,"schar")==0) fprintf(file_code,"sbyte[]");
						else if(strcmp(type->type,"int")==0)	  fprintf(file_code,"word[]");
						else if(strcmp(type->type,"sint")==0)  fprintf(file_code,"sword[]");
						else if(strcmp(type->type,"long")==0)  fprintf(file_code,"dword[]");
						else if(strcmp(type->type,"slong")==0) fprintf(file_code,"sdword[]");
						else fprintf(file_code,"%s[] ",type->type);
					}
				else
					{
						if(strcmp(type->type,"byte")==0)  fprintf(file_code,"byte");
						else if(strcmp(type->type,"char")==0)  fprintf(file_code,"byte");
						else if(strcmp(type->type,"schar")==0) fprintf(file_code,"sbyte");
						else if(strcmp(type->type,"int")==0)	  fprintf(file_code,"word");
						else if(strcmp(type->type,"sint")==0)  fprintf(file_code,"sword");
						else if(strcmp(type->type,"long")==0)  fprintf(file_code,"dword");
						else if(strcmp(type->type,"slong")==0) fprintf(file_code,"sdword");
						else fprintf(file_code,"%s",type->type);
					}

				/*if(etat_trace2==1)
					fprintf(file_code,"\n//%s type=%s index = %d genre = %d",
						decalage,
						type->type,
						recherche_type(type->type),
						type->genre_variable);

				if(etat_trace2==1)  fprintf(file_code,"\n// %s STRUCTURE ",decalage);
				if(etat_trace2==1)  fprintf(file_code," bloc = %s nb champ %d dimension %d",
					type->bloc,
					type->nb_champ,
					type->nb_dimension);*/

				/*for(i=0;i<type->nb_champ;i++)
					{
						if(etat_trace2==1) fprintf(file_code,"\n//%s champ # %d",decalage,i);
						/*affiche_type(type->type_variable_ptr[i],prof+1);*/
					/*}*/
				if (type->nb_dimension>0) if(etat_trace2==1) printf("\n%s",decalage);
				for(i=0;i<type->nb_dimension;i++)
						if(etat_trace2==1) fprintf(file_code,"[%d]",type->dimension[i]);
			}


		/*if(type->genre_variable==CHAMP)
			{
				if(traceaff==1) printf("\n%s champ %s ",decalage,type->champ_structure);

				if(traceaff==1) printf(" bloc = %s dimension %d",
					type->bloc,
					type->nb_dimension);

				if(type->type_pointeur==PASPOINTEUR) {if(traceaff==1) printf(" pas pointeur ");}
				if(type->type_pointeur==POINTEUR) {if(traceaff==1) printf(" * pointeur ");}
				if(type->type_pointeur==POINTEURPOINTEUR) {if(traceaff==1) printf(" ** pointeur ");}

				affiche_type(&tab_type_variable[recherche_type(type->type)],prof+1);

				if (type->nb_dimension>0)if(traceaff==1) {printf("\n%s",decalage);}
				for(i=0;i<type->nb_dimension;i++)
						if(traceaff==1) printf("[%d]",type->dimension[i]);
			}*/

		if(type->genre_variable==TABLEAU)
			{
				if(type->nb_dimension>0)
					{
						if(strcmp(type->type,"byte")==0)  fprintf(file_code,"byte[]");
						else if(strcmp(type->type,"char")==0)  fprintf(file_code,"byte[]");
						else if(strcmp(type->type,"schar")==0) fprintf(file_code,"sbyte[]");
						else if(strcmp(type->type,"int")==0)	  fprintf(file_code,"word[]");
						else if(strcmp(type->type,"sint")==0)  fprintf(file_code,"sword[]");
						else if(strcmp(type->type,"long")==0)  fprintf(file_code,"dword[]");
						else if(strcmp(type->type,"slong")==0) fprintf(file_code,"sdword[]");
						else fprintf(file_code,"%s[] ",type->type);
					}

				/*if(etat_trace2==1)
					fprintf(file_code,"\n//%s type=%s index = %d genre = %d",
						decalage,
						type->type,
						recherche_type(type->type),
						type->genre_variable);

				if(etat_trace2==1)  fprintf(file_code,"\n// %s TABLEAU ",decalage);*/
				/*if(etat_trace2==1)  fprintf(file_code," bloc = %s nb dimension %d ",type->bloc,type->nb_dimension);*/
				/*if(type->type_pointeur==PASPOINTEUR) { if(etat_trace2==1)fprintf(file_code," pas pointeur "); }
				if(type->type_pointeur==POINTEUR) { if(etat_trace2==1)fprintf(file_code," * pointeur "); }
				if(type->type_pointeur==POINTEURPOINTEUR) { if(etat_trace2==1) fprintf(file_code," ** pointeur "); }*/

				/*affiche_type(&tab_type_variable[recherche_type(type->type)],prof+1);*/

				/*if(etat_trace2==1)
				   {
					   	/*fprintf(file_code,"\n//%s",decalage);*/

						/*for(i=0;i<type->nb_dimension;i++)
							fprintf(file_code,"[%d]",type->dimension[i]);
				   }*/
			}
	}

char * convertit_type_gen(char *,int);

/* fonction de generation de variables */

void genere_variables(char *bloc1,int lib,int ind_fonction)
 {
	 int i;
	 char bloc[100];

	 if(strcmp(bloc1,"0")==0)
		 strcpy(bloc,"globale");
	 else
		 strcpy(bloc,bloc1);

	 if(strcmp(bloc1,"0")!=0)
		 {
			  int j;


			  if(etat_trace2==1) fprintf(file_code,"\n//%s DECLARATION DES VARIABLES EXPR du BLOC '%s'", affiche,bloc);
			 /* fprintf(file_code,"\ndseg segment");*/

			  if(lib==0) /* ce n'est pas une fonction de la librairie */
				  {
					/* for arrxx instructions */
					fprintf(file_code,"\n\tsize_word_%s   word",bloc1);
				  	fprintf(file_code,"\n\tlength_word_%s   word",bloc1);
				  	fprintf(file_code,"\n\tindex_word_%s   word",bloc1);

					/* for arrinit instruction */
					fprintf(file_code,"\n\tvalue_byte_%s   byte",bloc1);
			  		fprintf(file_code,"\n\tvalue_sbyte_%s  sbyte",bloc1);
			  		fprintf(file_code,"\n\tvalue_word_%s   word",bloc1);
			  		fprintf(file_code,"\n\tvalue_sword_%s  sword",bloc1);
			  		fprintf(file_code,"\n\tvalue_dword_%s  dword",bloc1);
			  		fprintf(file_code,"\n\tvalue_sdword_%s sdword",bloc1);

			  		fprintf(file_code,"\n\texpr_g_byte_%s   byte",bloc1);
			  		fprintf(file_code,"\n\texpr_g_sbyte_%s  sbyte",bloc1);
			  		fprintf(file_code,"\n\texpr_g_word_%s   word",bloc1);
			  		fprintf(file_code,"\n\texpr_g_sword_%s  sword",bloc1);
			  		fprintf(file_code,"\n\texpr_g_dword_%s  dword",bloc1);
			  		fprintf(file_code,"\n\texpr_g_sdword_%s sdword",bloc1);

			 		fprintf(file_code,"\n\texpr_d_byte_%s   byte",bloc1);
			  		fprintf(file_code,"\n\texpr_d_sbyte_%s  sbyte",bloc1);
			  		fprintf(file_code,"\n\texpr_d_word_%s   word",bloc1);
			  		fprintf(file_code,"\n\texpr_d_sword_%s  sword",bloc1);
			  		fprintf(file_code,"\n\texpr_d_dword_%s  dword",bloc1);
			  		fprintf(file_code,"\n\texpr_d_sdword_%s sdword",bloc1);

			  		fprintf(file_code,"\n\texpr_byte_%s   byte",bloc1);
			  		fprintf(file_code,"\n\texpr_sbyte_%s  sbyte",bloc1);
			  		fprintf(file_code,"\n\texpr_word_%s   word",bloc1);
			  		fprintf(file_code,"\n\texpr_sword_%s  sword",bloc1);
			  		fprintf(file_code,"\n\texpr_dword_%s  dword",bloc1);
			  		fprintf(file_code,"\n\texpr_sdword_%s sdword",bloc1);

			  		fprintf(file_code,"\n\texpr_aff_byte_%s   byte",bloc1);
			 		fprintf(file_code,"\n\texpr_aff_sbyte_%s  sbyte",bloc1);
			  		fprintf(file_code,"\n\texpr_aff_word_%s   word",bloc1);
			  		fprintf(file_code,"\n\texpr_aff_sword_%s  sword",bloc1);
			  		fprintf(file_code,"\n\texpr_aff_dword_%s  dword",bloc1);
			  		fprintf(file_code,"\n\texpr_aff_sdword_%s sdword",bloc1);

			  		/* tableau */

			  		fprintf(file_code,"\n\texpr_g_byte_tab_%s   byte[]",bloc1);
			  		fprintf(file_code,"\n\texpr_g_sbyte_tab_%s  sbyte[]",bloc1);
			  		fprintf(file_code,"\n\texpr_g_word_tab_%s   word[]",bloc1);
			  		fprintf(file_code,"\n\texpr_g_sword_tab_%s  sword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_g_dword_tab_%s  dword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_g_sdword_tab_%s sdword[]",bloc1);

			  		fprintf(file_code,"\n\texpr_d_byte_tab_%s   byte[]",bloc1);
			  		fprintf(file_code,"\n\texpr_d_sbyte_tab_%s  sbyte[]",bloc1);
			  		fprintf(file_code,"\n\texpr_d_word_tab_%s   word[]",bloc1);
			  		fprintf(file_code,"\n\texpr_d_sword_tab_%s  sword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_d_dword_tab_%s  dword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_d_sdword_tab_%s sdword[]",bloc1);

			  		fprintf(file_code,"\n\texpr_byte_tab_%s   byte[]",bloc1);
			 		fprintf(file_code,"\n\texpr_sbyte_tab_%s  sbyte[]",bloc1);
			  		fprintf(file_code,"\n\texpr_word_tab_%s   word[]",bloc1);
			  		fprintf(file_code,"\n\texpr_sword_tab_%s  sword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_dword_tab_%s  dword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_sdword_tab_%s sdword[]",bloc1);

			  		fprintf(file_code,"\n\texpr_aff_byte_tab_%s   byte[]",bloc1);
			  		fprintf(file_code,"\n\texpr_aff__sbyte_tab_%s  sbyte[]",bloc1);
			  		fprintf(file_code,"\n\texpr_aff_word_tab_%s   word[]",bloc1);
			  		fprintf(file_code,"\n\texpr_aff_sword_tab_%s  sword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_aff_dword_tab_%s  dword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_aff_tab_sdword_%s sdword[]",bloc1);

			   		fprintf(file_code,"\n\tinc_%s word",bloc);


					/* generation de la pile des expressions */

					fprintf(file_code,"\n\texpr_pile_byte_%s   byte[]",bloc1);
			  		fprintf(file_code,"\n\texpr_pile_sbyte_%s  sbyte[]",bloc1);
			  		fprintf(file_code,"\n\texpr_pile_word_%s   word[]",bloc1);
			  		fprintf(file_code,"\n\texpr_pile_sword_%s  sword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_pile_dword_%s  dword[]",bloc1);
			  		fprintf(file_code,"\n\texpr_pile_sdword_%s sdword[]",bloc1);

					fprintf(file_code,"\n\texpr_ptr_pile_byte_%s   word",bloc1);
			  		fprintf(file_code,"\n\texpr_ptr_pile_sbyte_%s  word",bloc1);
			  		fprintf(file_code,"\n\texpr_ptr_pile_word_%s   word",bloc1);
			  		fprintf(file_code,"\n\texpr_ptr_pile_sword_%s  word",bloc1);
			  		fprintf(file_code,"\n\texpr_ptr_pile_dword_%s  word",bloc1);
			  		fprintf(file_code,"\n\texpr_ptr_pile_sdword_%s word",bloc1);

				}
			  else /* c'est une fonction de la librairie */
			    {
					TYPE_VARIABLE *typ;
					char *typ_conv;

					typ=tab_fonction[ind_fonction].type_variable_retournee_ptr;

					if(strcmp(typ->type,"void")==0)
						{
							if(etat_trace2==1) fprintf(file_code,"\n//%s PAS DE TYPE RETOURNE '%s'", affiche,bloc1);
						}
					else
						{
							if(etat_trace2==1) fprintf(file_code,"\n//%s TYPE RETOURNE '%s' type ='%s' ", affiche,bloc1,typ->type);

							typ_conv=convertit_type_gen(typ->type,0);

							if(typ->genre_variable==TABLEAU)
								fprintf(file_code,"\n\texpr_%s_tab_%s   %s[]",typ_conv,bloc1,typ_conv);
							else
								fprintf(file_code,"\n\texpr_%s_%s   %s",typ_conv,bloc1,typ_conv);
						}
			    }

			  if(etat_trace2==1) fprintf(file_code,"\n//%s DECLARATION DES VARIABLES EXPR STRUCT du BLOC '%s'", affiche,bloc);

			  for(j=0;j<nb_tab_type_variable;j++)
	 		   {
					if(tab_type_variable[j].genre_variable==STRUCTURE)
						{
							fprintf(file_code,"\n\texpr_%s_%s %s",tab_type_variable[j].type,bloc,tab_type_variable[j].type);
							fprintf(file_code,"\n\texpr_aff_%s_%s %s",tab_type_variable[j].type,bloc,tab_type_variable[j].type);
							fprintf(file_code,"\n\texpr_aff_%s_tab_%s %s[]",tab_type_variable[j].type,bloc,tab_type_variable[j].type);
							fprintf(file_code,"\n\texpr_%s_tab_%s %s[]",tab_type_variable[j].type,bloc,tab_type_variable[j].type);
							fprintf(file_code,"\n\texpr_d_%s_tab_%s %s[]",tab_type_variable[j].type,bloc,tab_type_variable[j].type);
							fprintf(file_code,"\n\texpr_g_%s_tab_%s %s[]",tab_type_variable[j].type,bloc,tab_type_variable[j].type);

							/* for arrinit instruction */
							fprintf(file_code,"\n\tvalue_%s_%s %s[]",tab_type_variable[j].type,bloc,tab_type_variable[j].type);
					    }

			   }

			  if(etat_trace2==1) fprintf(file_code,"\n//%s DECLARATION DE LA PILE D'INDEX D'EVALUATION RECURSIVE DES TABLEAUX BLOC '%s'", affiche,bloc);

			  fprintf(file_code,"\n\tindex_tab_%s dword[]",bloc1);
			  fprintf(file_code,"\n\tindex_%s dword 0",bloc1);
			  fprintf(file_code,"\n\tindex_%s_cumul dword 0",bloc1);

			  if(etat_trace2==1) fprintf(file_code,"\n//%s DECLARATION DES VARIABLES LOCALE  du BLOC '%s'", affiche,bloc);


	     }
	 else
	     {
			  if(etat_trace2==1) fprintf(file_code,"\n//%s DECLARATION DES VARIABLES d'EVALUATION des EXPR GLOBALE", affiche);

			  for(i=0;i<nb_instruction;i++)
				  {
					 if(tab_instruction[i].type_instruction==INST_SWITCH) fprintf(file_code,"\n\texpr_switch_%d sdword",
				 			tab_instruction[i].index);
				  }

		 }

	  for(i=0;i<program.nb_vg;i++)
		{
	  		if(strcmp(program.vg[i].bloc,bloc1)==0)
				{

					if(etat_trace2==1) fprintf(file_code,"\n//DECLARATION VARIABLE '%s' bloc '%s' valeur '%s' lg=%d type = '%s' typs = %d %d %d ",
					 		program.vg[i].ident,
							program.vg[i].bloc,
							program.vg[i].valeur,strlen(program.vg[i].valeur),
							program.vg[i].type_variable_ptr->type,
							program.vg[i].type_variable_ptr->genre_variable,TABLEAU,strlen(program.vg[i].valeur));

					if(etat_trace2==1)
						{
							if(program.vg[i].type_pointeur==PASPOINTEUR)
								fprintf(file_code,"PAS POINTEUR");
							if(program.vg[i].type_pointeur==POINTEUR)
								fprintf(file_code,"TABLEAU");
							if(program.vg[i].type_pointeur==POINTEURPOINTEUR)
								fprintf(file_code,"TABLEAU");
						}

					if(strcmp(program.vg[i].type_variable_ptr->type,"float")!=0)
						{

							/* patch 20/08 */

							fprintf(file_code,"\n\t%s_%s ",bloc,program.vg[i].ident);

							if((program.vg[i].type_pointeur!=POINTEURPOINTEUR)&&(program.vg[i].type_pointeur!=POINTEUR))
								fprintf(file_code," ");

							genere_type_variable(program.vg[i].type_variable_ptr,0);

							if(program.vg[i].type_pointeur==POINTEUR)
								fprintf(file_code,"[]");
							if(program.vg[i].type_pointeur==POINTEURPOINTEUR)
								fprintf(file_code,"[]");

						}
					else
						fprintf(file_code,"\n// variable de type float ignoree  \t%s_%s float ",bloc,program.vg[i].ident);



					if(strlen(program.vg[i].valeur)>0)
						{
							/*printf("\n affectation valeur %d %s",program.vg[i].type_variable_ptr->genre_variable,program.vg[i].type_variable_ptr->type);*/
							if ((program.vg[i].type_variable_ptr->genre_variable==TABLEAU)&&
								(strcmp(program.vg[i].type_variable_ptr->type,"char")==0))
								{
										fprintf(file_code," '%s'",program.vg[i].valeur);
										/*printf(" '%s'",program.vg[i].valeur);*/
								}
							else
								fprintf(file_code," %s",program.vg[i].valeur);
						}

				}
		}

	 if(strcmp(bloc1,"0")!=0)
		 {
			 	 if(etat_trace2==1) fprintf(file_code,"\n//%s FIN DECLARATION DES VARIABLES du BLOC '%s'", affiche,bloc);
				/* fprintf(file_code,"\ndseg ends");*/
	     }
 }

/* convertit type */

char * convertit_type_gen(char *type,int tab)
 {
	 char *rtype;


	 if(tab==0) /* ce n'est pas un tableau */
		 {
	 		if(strcmp(type,"byte")==0)  		rtype=(char *)&tab_atome[0];
			else if(strcmp(type,"char")==0) 	rtype=(char *)&tab_atome[0];
			else if(strcmp(type,"schar")==0) 	rtype=(char *)&tab_atome[1];
			else if(strcmp(type,"int")==0)	 	rtype=(char *)&tab_atome[2];
			else if(strcmp(type,"sint")==0) 	rtype=(char *)&tab_atome[3];
			else if(strcmp(type,"long")==0)  	rtype=(char *)&tab_atome[4];
			else if(strcmp(type,"slong")==0) 	rtype=(char *)&tab_atome[5];
			else rtype=type;
		}
	 else /* c'est un tableau */
		{
			if(strcmp(type,"byte")==0)  		rtype=(char *)&tab_atome[6];
			else if(strcmp(type,"char")==0) 	rtype=(char *)&tab_atome[6];
			else if(strcmp(type,"schar")==0) 	rtype=(char *)&tab_atome[7];
			else if(strcmp(type,"int")==0)	 	rtype=(char *)&tab_atome[8];
			else if(strcmp(type,"sint")==0) 	rtype=(char *)&tab_atome[9];
			else if(strcmp(type,"long")==0)  	rtype=(char *)&tab_atome[10];
			else if(strcmp(type,"slong")==0) 	rtype=(char *)&tab_atome[11];
			else
				{
					int i;

					for(i=12;i<max_tab_atome;i++)
						if(strcmp(type,tab_atome[i])==0) rtype=(char *)&tab_atome[i];
				}
		}

	 return(rtype);
 }

/* recherche un atome */

int recherche_atome(char *t)
 {
	 int i;

	 for(i=0;i<6;i++)
		 if(strcmp(tab_atome[i],t)==0) break;

	 if(i==6) return(-1);
	 else return(i);
 }

/* recherche un tableau d'atome */


int recherche_tab_atome(char *t)
 {
	 int i;

	 for(i=6;i<12;i++)
		 if(strcmp(tab_atome[i],t)==0) break;

	 if(i==12) return(-1);
	 else return(i);
 }


/* genere variable */

char * genere_recursif(SEXPRESSION *,int,char *,char *);

char derniere_variable[MAX_IDENT];

char * genere_variable(SEXPRESSION *exp,int aff,char *bloc,char *type_aff)
	{
		int i;
		SVARIABLE *chaine,*prec;
		char nom_variable[10000];
		char *rtype;
		int ligne;

		if(strcmp(exp->feuille.svariable.variable_ptr->bloc,"0")==0)
			sprintf(nom_variable,"globale_%s",exp->feuille.svariable.variable_ptr->ident);
		else
		 	sprintf(nom_variable,"%s_%s",exp->feuille.svariable.variable_ptr->bloc, exp->feuille.svariable.variable_ptr->ident);
 /*printf("\n F %s",nom_variable);*/

 		ligne=exp->feuille.svariable.ligne;
		prec=chaine=exp->feuille.svariable.suivant;

		if(chaine==NULL)
			{

				if(etat_trace2==1) fprintf(file_code,"\n// TYPE VARIABLE=%s NOM = '%s' DIM = %d",
					exp->feuille.svariable.variable_ptr->type_variable_ptr->type,
					nom_variable,
					exp->feuille.svariable.variable_ptr->type_variable_ptr->nb_dimension);

				/*printf("\n// #1 TYPE VARIABLE=%s NOM = '%s'",exp->feuille.svariable.variable_ptr->type_variable_ptr->type,nom_variable);*/

				rtype=exp->feuille.svariable.variable_ptr->type_variable_ptr->type;

			}

		for(;chaine!=NULL;)
			{
				switch(chaine->type_svariable)
					{
						case SVARIABLE_TABLEAU_SEUL :
							{
								int i,j,cumul;
								char *type_index;

								if(etat_trace2==1) fprintf(file_code,"\n//%s Tableau seul type '%s' ",affiche,chaine->type->type);

								fprintf(file_code,"\n\tset index_%s_cumul, 0",bloc);

								for(i=0;i<chaine->nb_dimension;i++)
									{
										if(etat_trace2==1) fprintf(file_code,"\n//%s dimension '%d' [%d]",affiche,i,chaine->type->dimension[i]);

										if(chaine->dimension[i]->type!=EXP_ATOME)
											{
												if(etat_trace2==1) fprintf(file_code,"\n//SAUVEGARDE DANS LA PILE DES INDEX ");
												fprintf(file_code,"\n\treplace index_tab_%s, index_tab_%s, index_%s, index_%s_cumul",bloc,bloc,bloc,bloc);
												fprintf(file_code,"\n\tset inc_%s, 1",bloc);
												fprintf(file_code,"\n\tadd index_%s, index_%s, inc_%s",bloc,bloc,bloc);
											}

										type_index=genere_recursif(chaine->dimension[i],0,bloc,NULL);

										if(recherche_atome(type_index)==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0040,
													bloc,nom_variable,type_index,i);
		 										message_erreur(libelle);
											}

										if(chaine->dimension[i]->type!=EXP_ATOME)
											{
												fprintf(file_code,"\n\tset inc_%s, 1",bloc);
												fprintf(file_code,"\n\tsub index_%s, index_%s, inc_%s",bloc,bloc,bloc);
												fprintf(file_code,"\n\tindex index_%s_cumul, index_tab_%s, index_%s ",bloc,bloc,bloc);
											}

										if(chaine->nb_dimension>1)
											{
												cumul=1;
												for(j=chaine->nb_dimension-1;j>i;j--)
													cumul=cumul*chaine->type->dimension[j];

												fprintf(file_code,"\n\tmov expr_g_word_%s, expr_%s_%s",bloc,type_index,bloc);
												fprintf(file_code,"\n\tset expr_d_word_%s, %d",bloc,cumul);
												fprintf(file_code,"\n\tmul expr_word_%s, expr_g_word_%s, expr_d_word_%s",bloc,bloc,bloc);
												fprintf(file_code,"\n\tadd index_%s_cumul, index_%s_cumul, expr_word_%s",bloc,bloc,bloc);
											}
										else
											{
												fprintf(file_code,"\n\tmov index_%s_cumul, expr_%s_%s",bloc,type_index,bloc);
											}
									}

								if(aff==0)
									{
										char *typ_conv;

										typ_conv=convertit_type_gen(chaine->type->type,0);

										if(etat_trace2==1) fprintf(file_code,"\n// AFFECTATION type du tableau ='%s'/'%s'",chaine->type->type,typ_conv);
/* patch */
										fprintf(file_code,"\n\tindex expr_%s_%s, %s, index_%s_cumul // SVARIABLE_TABLEAU_SEUL '%s' / '%s'",
												typ_conv/*chaine->type->type*/,bloc,nom_variable,bloc,chaine->type->type,typ_conv);
									}


								rtype=chaine->type->type;

							} break;
						case SVARIABLE_CHAMP_SEUL:
							{
								if(etat_trace2==1) fprintf(file_code,"\n//%s Champ seul ",affiche);
								if(etat_trace2==1) fprintf(file_code," champ '%s' type '%s'",chaine->ident_champ,chaine->type->type);
								sprintf(nom_variable,"%s.%s",nom_variable,chaine->ident_champ);
								if(etat_trace2==1) fprintf(file_code,"\n//%s cumul = %s ",affiche,nom_variable);
								if(chaine->indirection==LPOINT) {if(etat_trace2==1) fprintf(file_code," '.' ");}
								if(chaine->indirection==LINDIRECT) {if(etat_trace2==1) fprintf(file_code," '->' ");}

								rtype=chaine->type->type;

								/*printf("\nvariable %s",nom_variable);*/

							} break;
						case SVARIABLE_CHAMP_TABLEAU:
							{
								int i,j,cumul;
								char *type_index;

								if(etat_trace2==1) fprintf(file_code,"\n//%s Champ tableau ",affiche);
								if(etat_trace2==1) fprintf(file_code," champ '%s' type '%s' ",chaine->ident_champ,chaine->type->type);

								fprintf(file_code,"\n\tset expr_index, 0");

								for(i=0;i<chaine->nb_dimension;i++)
									{
										if(etat_trace2==1) fprintf(file_code,"\n//%s dimension '%d' [%d]",affiche,i,chaine->type->dimension[i]);

										if(chaine->dimension[i]->type!=EXP_ATOME)
											{
												if(etat_trace2==1) fprintf(file_code,"\n//SAUVEGARDE DANS LA PILE DES INDEX ");
												fprintf(file_code,"\n\treplace index_tab_%s, index_tab_%s, index_%s, index_%s_cumul",bloc,bloc,bloc,bloc);
												fprintf(file_code,"\n\tset inc_%s, 1",bloc);
												fprintf(file_code,"\n\tadd index_%s, index_%s, inc_%s",bloc,bloc,bloc);
											}

										type_index=genere_recursif(chaine->dimension[i],0,bloc,NULL);

										if(recherche_atome(type_index)==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0050,
													bloc,nom_variable,type_index,i);
		 										message_erreur(libelle);
											}

										if(chaine->dimension[i]->type!=EXP_ATOME)
											{
												fprintf(file_code,"\n\tset inc_%s, 1",bloc);
												fprintf(file_code,"\n\tsub index_%s, index_%s, inc_%s",bloc,bloc,bloc);
												fprintf(file_code,"\n\tindex index_%s_cumul, index_tab_%s, index_%s, ",bloc,bloc,bloc);
											}

										cumul=1;
										for(j=chaine->nb_dimension-1;j>i;j--)
											cumul=cumul*chaine->type->dimension[j];

										fprintf(file_code,"\n\tmov expr_g_word_%s, expr_%s_%s",bloc,type_index,bloc);
										fprintf(file_code,"\n\tset expr_d_word_%s, %d",bloc,cumul);
										fprintf(file_code,"\n\tmul expr_word_%s, expr_g_word_%s, expr_d_word_%s",bloc,bloc,bloc);
										fprintf(file_code,"\n\tadd index_%s_cumul, index_%s_cumul, expr_word_%s",bloc,bloc,bloc);
									}

								if(aff==0)
									{
										char *typ_conv;

										typ_conv=convertit_type_gen(chaine->type->type,0);

										if(etat_trace2==1) fprintf(file_code,"\n// AFFECTATION  champ '%s' type '%s' / '%s' ",
											chaine->ident_champ,chaine->type->type,typ_conv);
/* patch */
										fprintf(file_code,"\n\tindex expr_%s_%s, %s, index_%s_cumul // SVARIABLE_CHAMP_TABLEAU '%s'/'%s'",
											    typ_conv,bloc,nom_variable,bloc,chaine->type->type,typ_conv);
									}

								rtype=chaine->type->type;

							} break;
					}
				chaine=chaine->suivant;
			}

		if(aff==0) /* expression */
			{
				char *rtype1;
				/*printf("\n expression %s",nom_variable);*/

				rtype1=rtype;

				if(prec!=NULL)
					{
						rtype=convertit_type_gen(rtype,0);

						if(prec->type_svariable==SVARIABLE_CHAMP_SEUL)
							{
								fprintf(file_code,"\n\tmov expr_%s_%s, %s // aff 0",rtype,bloc,nom_variable);
							}
					}
				else
					{
						rtype=convertit_type_gen(rtype,0);

						if(
						   (exp->feuille.svariable.variable_ptr->type_variable_ptr->nb_dimension==0) && /* ce n'est ps un tableau */
						   (exp->feuille.svariable.variable_ptr->/*type_variable_ptr->*/type_pointeur==PASPOINTEUR)
						  )
							fprintf(file_code,"\n\tmov expr_%s_%s, %s // aff 1",rtype,bloc,nom_variable);

						if(
						    (exp->feuille.svariable.variable_ptr->type_variable_ptr->nb_dimension>0)||
						    (
							 (exp->feuille.svariable.variable_ptr->type_variable_ptr->nb_dimension==0)&& /* ce n'est ps un tableau */
						     (exp->feuille.svariable.variable_ptr->type_pointeur==POINTEUR)
						    )
						  )
						/* c'est un tableau */
							{
								fprintf(file_code,"\n\tmov expr_%s_tab_%s, %s // aff 2",rtype,bloc,nom_variable);
								/*printf("\n\tmov expr_%s_tab_%s, %s",rtype,bloc,nom_variable);*/
								rtype=convertit_type_gen(rtype1,1); /* type tableau */
							}
					}
			}
		else if(aff==1) /* affectation */
			{
				char *rtype1;

				rtype1=rtype;

				/*printf("\n affectation %s",nom_variable);*/
				if(prec==NULL)
					{
						/*printf("\n prec==NULL");*/

						rtype=convertit_type_gen(rtype,0);

						if(exp->feuille.svariable.variable_ptr->type_variable_ptr->nb_dimension==0)
							{
								/*printf("\n ce n'est pas un tableau ");*/
								fprintf(file_code,"\n\tmov %s, expr_aff_%s_%s // aff 3",nom_variable,type_aff,bloc);
							}
						else /* c'est un tableau */
							{
								int ind_tab;

								/*printf("\n c'est un tableau ");*/
		/* correction à apporter, supprimer le tab si tableau d'atome  */

								ind_tab=recherche_tab_atome(type_aff);

								if(ind_tab==-1)
									fprintf(file_code,"\n\tmov %s, expr_aff_%s_tab_%s // aff 4 ",nom_variable,type_aff,bloc);
								else
									fprintf(file_code,"\n\tmov %s, expr_aff_%s_%s // aff 4 tab atome ",nom_variable,type_aff,bloc);

								rtype=convertit_type_gen(rtype1,1); /* type tableau */
							}
					}
				else
					{
						/*printf("\n prec!=NULL ");*/

						rtype=convertit_type_gen(rtype,0);

						if(prec->type_svariable==SVARIABLE_CHAMP_SEUL)
							{
								/*printf("\n SVARIABLE_CHAMP_SEUL");*/
								fprintf(file_code,"\n\tmov %s, expr_aff_%s_%s",nom_variable,type_aff,bloc);
							}

						if(prec->type_svariable==SVARIABLE_TABLEAU_SEUL)
							{
								/*printf("\nSVARIABLE_TABLEAU_SEUL");*/
								fprintf(file_code,"\n\treplace %s, %s, index_%s_cumul, expr_aff_%s_%s",nom_variable,nom_variable,bloc,type_aff,bloc);
							}

						if(prec->type_svariable==SVARIABLE_CHAMP_TABLEAU)
							{
								/*printf("\n SVARIABLE_CHAMP_TABLEAU");*/
								fprintf(file_code,"\n\treplace %s, %s, index_%s_cumul, expr_aff_%s_%s",nom_variable,nom_variable,bloc,type_aff,bloc);
							}
					}

			}
		else if(aff==2) /* increment */
			{
						rtype=convertit_type_gen(rtype,0);

						if(recherche_atome(rtype)==-1)
							{
								char libelle[200];

			 					sprintf(libelle,GC0060,
													bloc,nom_variable,rtype);
		 						message_erreur(libelle);
							}

						fprintf(file_code,"\n\tset expr_g_%s_%s, 1",rtype,bloc);
						fprintf(file_code,"\n\tadd %s, %s, expr_g_%s_%s",
								nom_variable,nom_variable,rtype,bloc);
						fprintf(file_code,"\n\tmov expr_%s_%s, %s",
								rtype,bloc,nom_variable);
			}
		else if(aff==3) /* decrement */
			{
						rtype=convertit_type_gen(rtype,0);

						if(recherche_atome(rtype)==-1)
							{
								char libelle[200];

			 					sprintf(libelle,GC0070,
													bloc,nom_variable,rtype);
		 						message_erreur(libelle);
							}

						fprintf(file_code,"\n\tset expr_g_%s_%s, 1",rtype,bloc);
						fprintf(file_code,"\n\tsub %s, %s, expr_g_%s_%s",
								nom_variable,nom_variable,rtype,bloc);
						fprintf(file_code,"\n\tmov expr_%s_%s, %s",
								rtype,bloc,nom_variable);
			}

		if(etat_trace2==1) fprintf(file_code,"\n//%s VARIABLE '%s'",
								affiche,
								exp->feuille.svariable.variable_ptr->ident);

		if(exp->feuille.svariable.indirection==TYP_PTR_VAR_ADRESSE) {if(etat_trace2==1) fprintf(file_code," type ptr = '&' ");}
	 	if(exp->feuille.svariable.indirection==TYP_PTR_VAR_NORMAL) {if(etat_trace2==1) fprintf(file_code," type ptr ='normal' ");}
	 	if(exp->feuille.svariable.indirection==TYP_PTR_VAR_POINTEUR) {if(etat_trace2==1) fprintf(file_code," type ptr = '*' ");}
	 	if(exp->feuille.svariable.indirection==TYP_PTR_VAR_POINTEUR_POINTEUR) {if(etat_trace2==1) fprintf(file_code," type ptr = '**' ");}

		if(etat_trace2==1) fprintf(file_code,"\n//%s ident '%s' bloc '%s' valeur '%s' / type '%s' ",
								affiche,
								exp->feuille.svariable.variable_ptr->ident ,
								exp->feuille.svariable.variable_ptr->bloc,
								exp->feuille.svariable.variable_ptr->valeur,
								exp->feuille.svariable.variable_ptr->type_variable_ptr->type);

		if(exp->feuille.svariable.variable_ptr->type_pointeur==POINTEUR)
			{if(etat_trace2==1) fprintf(file_code," 'POINTEUR' ");}
		if(exp->feuille.svariable.variable_ptr->type_pointeur==PASPOINTEUR)
			{if(etat_trace2==1) fprintf(file_code," 'PASPOINTEUR' ");}
		if(exp->feuille.svariable.variable_ptr->type_pointeur==POINTEURPOINTEUR)
			{if(etat_trace2==1) fprintf(file_code," 'POINTEURPOINTEUR' ");}

		/*rtype=convertit_type_gen(rtype);*/

		if(etat_trace2==1) fprintf(file_code,"\n//%s TYPE VARIABLE '%s'",
								affiche,rtype);

		/* sauvegarde du dernier nom de variable */

		strcpy(derniere_variable,nom_variable);

		return(rtype);
	}

/* calcul type */

char matrice[6][6]=
	{                 /* byte   sbyte  word   sword  dword sdword */
		/* byte   */ {   0,     1,     2,     3,     4,    5        },
		/* sbyte  */ {   1,     1,     3,     3,     5,    5        },
		/* word   */ {   2,     3,     2,     3,     4,    5        },
		/* sword  */ {   3,     3,     3,     3,     5,    5        },
		/* dword  */ {   4,     5,     4,     5,     4,    5        },
		/* sdword */ {   5,     5,     5,     5,     5,    5        }
	};

char * calcul_type_resultant(char *rtypeg, char *rtyped)
 {
	 int x,y;

	 if(rtypeg==NULL)
		 return(rtyped);

	 if(rtyped==NULL)
		 return(rtypeg);

	 for(x=0;x<6;x++)
	 	if(strcmp(tab_atome[x],rtypeg)==0) break;

	 for(y=0;y<6;y++)
	 	if(strcmp(tab_atome[y],rtyped)==0) break;

	 if((x==6)&&(y==6))
		 {
			 if(strcmp(rtypeg,rtyped)==0)
				 return(rtypeg);
			 else
				{
					if(etat_trace2==1) fprintf(file_code,"\n// ERRREUR TYPE INCOMPATIBLE %s %s ",rtypeg,rtyped);
					return(rtypeg);
				}
		 }

	 if((x==6)&&(y<6))
		 {
			if(etat_trace2==1) fprintf(file_code,"\n// ERRREUR TYPE INCOMPATIBLE %s %s ",rtypeg,rtyped);
			return(rtypeg);
		 }

	 if((x<6)&&(y==6))
		 {
			if(etat_trace2==1) fprintf(file_code,"\n// ERRREUR TYPE INCOMPATIBLE %s %s ",rtypeg,rtyped);
			return(rtypeg);
		 }

	 return(tab_atome[matrice[x][y]]);
 }

/* cast */

void cast_type(char *bloc,char **rtypeg,char **rtyped,char *rtype)
 {
	  if(rtypeg!=rtyped) /* les 2 types sont differents */
	   {
		   	if(*rtypeg==rtype)
				{
					fprintf(file_code,"\n\tmov expr_d_%s_%s, expr_d_%s_%s",rtype,bloc,*rtyped,bloc);
					*rtyped=*rtypeg;
				}
			else if(*rtyped==rtype)
				{
					fprintf(file_code,"\n\tmov expr_g_%s_%s, expr_g_%s_%s",rtype,bloc,*rtypeg,bloc);
					*rtypeg=*rtyped;
				}
			else
				{
					char libelle[200];

			 		sprintf(libelle,GC0080,
															 	bloc,*rtypeg,*rtyped,rtype);
		 			message_erreur(libelle);
				}
	   }
 }

/* genere les expressions */

char * genere_recursif(SEXPRESSION *exp,int aff,char *bloc,char *type_aff)
 {

	 char aff_op[100];
	 char aff_type[100];
	 char *rtype,*rtypeg,*rtyped;

	 rtype=(char *)&tab_atome[0];

	/*  fprintf(file_code,"\n\t<code expression> ");*/

	 monte();

	 if(exp==NULL)
		 {
		 	if(etat_trace2==1) fprintf(file_code,"\n//%s Feuille NULL ",affiche);
		 }
	 else
	 	switch(exp->type)
		  {
					case EXP_ATOME:
						{
							/*monte();*/

							switch(exp->feuille.satome.type)
						 	 {
								 case LCHIFFREENT:
									 {
										 long v;

										 strcpy(aff_type,"ENTIER");

										 v=atoi(exp->feuille.satome.valeur);

										 if(v<=255)
											 rtype=(char *)&tab_atome[0];
										 else
										 	 if(v<=65535) rtype=(char *)&tab_atome[2];
										 else
											 if(v>65535) rtype=(char *)&tab_atome[4]; /* patch */

										 if(etat_trace2==1) fprintf(file_code,"\n// TYPE = %s",rtype);

										/* printf("\n// ATOME TYPE = %s",rtype);*/

										 fprintf(file_code,"\n\tset expr_%s_%s, %s",rtype,bloc,exp->feuille.satome.valeur);


									 }break;
								 case LCHIFFRREEL:
									 {
										 strcpy(aff_type,"REEL");
									 }break;
								 case CHAINE:
									 {
										 strcpy(aff_type,"CHAINE");
										 rtype=(char *)&tab_atome[6];
										 /*fprintf(file_code,"\n\tstrtoarr expr_%s_tab_%s, '%s'",rtype,bloc,exp->feuille.satome.valeur);*/
										 fprintf(file_code,"\n\tmov expr_%s_%s, '%s'",rtype,bloc,exp->feuille.satome.valeur);

									 }break;
								 case LIDENT:
									 {
										 strcpy(aff_type,"Ident");
									 }break;
							 }

							if(etat_trace2==1) fprintf(file_code,"\n//%s ATOME %s OP = %d TYPE = %d/%s ",
								affiche,
								exp->feuille.satome.valeur,
								exp->operateur,
								exp->feuille.satome.type,
								aff_type);

							/*descend();*/

						}break;
					case EXP_VARIABLE:
						{
 /*printf("\n D");*/
 								/*printf("\n variable ");*/
								rtype=genere_variable(exp,aff,bloc,type_aff);
 /*printf("\n E '%s'",rtype);*/

						}break;
					case EXP_POINTEUR:
						{

							if(type_aff==0) /* expression côte valeur affectee */
								{
									/*printf("\n pointeur ");*/

									if(etat_trace2==1) fprintf(file_code,"\n//%s EXPR POINTEUR *(%s + index ) type = '%s'",
																affiche,
																exp->feuille.spointeur.ident_variable,
																exp->feuille.spointeur.variable_ptr->type_variable_ptr->type);

									if(etat_trace2==1) fprintf(file_code,"\n//%s GENERATION INDEX POINTEUR",affiche);

									/*printf("\n genere expr index  ");*/
									/*printf("\n//%s POINTEUR *(%s  + index ) type = '%s'",
												affiche,
												exp->feuille.spointeur.ident_variable,
												exp->feuille.spointeur.variable_ptr->type_variable_ptr->type);*/

									rtyped=genere_recursif(exp->feuille.spointeur.index,0,bloc,NULL);

									/*printf("\n fin genere expr index  ");*/

									rtype=convertit_type_gen(exp->feuille.spointeur.variable_ptr->type_variable_ptr->type,0);

									fprintf(file_code,"\n\tindex expr_%s_%s, %s_%s, expr_%s_%s",
											rtype,
											bloc,
											bloc,exp->feuille.spointeur.ident_variable,
											rtyped,
											bloc);

									if(etat_trace2==1) fprintf(file_code,"\n//%s FIN EXPR DE GENERATION INDEX POINTEUR",affiche);
						 	    }
							else /* côte variable affectee */
								{

									if(etat_trace2==1) fprintf(file_code,"\n//%s AFF POINTEUR *(%s + index ) type = '%s'",
																affiche,
																exp->feuille.spointeur.ident_variable,
																exp->feuille.spointeur.variable_ptr->type_variable_ptr->type);

									if(etat_trace2==1) fprintf(file_code,"\n//%s GENERATION INDEX POINTEUR",affiche);


									rtyped=genere_recursif(exp->feuille.spointeur.index,0,bloc,NULL);

									rtype=convertit_type_gen(exp->feuille.spointeur.variable_ptr->type_variable_ptr->type,0);

									fprintf(file_code,"\n\treplace %s_%s, %s_%s, expr_%s_%s, expr_aff_%s_%s",
											bloc,exp->feuille.spointeur.ident_variable,
											bloc,exp->feuille.spointeur.ident_variable,
											rtyped,
											bloc,
											type_aff,
											bloc);

									if(etat_trace2==1) fprintf(file_code,"\n//%s FIN AFF DE GENERATION INDEX POINTEUR",affiche);
								}

						}break;
					case EXP_OPERATEUR:
						{
							/*monte();*/

							switch(exp->operateur)
						 	 {
								 case LSHL:
									 {
										 strcpy(aff_op," '<<' ");
									 }break;
								 case LSHR:
									 {
										 strcpy(aff_op," '>>' ");
									 }break;
								 case LMUL:
									 {
										 strcpy(aff_op," '*' ");
									 }break;
								 case LDIV:
									 {
										 strcpy(aff_op," '/' ");
									 }break;
								 case LMODULO:
									 {
										 strcpy(aff_op," '%' ");
									 }break;
								 case LPLUS:
									 {
										 strcpy(aff_op," '+' ");
									 }break;
								 case LMOINS:
									 {
										 strcpy(aff_op," '-' ");
									 }break;
								 case LCOMPET:
									 {
										 strcpy(aff_op," '&&' ");
									 }break;
								 case LCOMPOU:
									 {
										 strcpy(aff_op," '||' ");
									 }break;
								 case LCOMPINF:
									 {
										 strcpy(aff_op," '<' ");
									 }break;
								 case LCOMPSUP:
									 {
										 strcpy(aff_op," '>' ");
									 }break;
								 case LCOMPINFEG:
									 {
										 strcpy(aff_op," '<=' ");
									 }break;
								 case LCOMPSUPEG:
									 {
										 strcpy(aff_op," '>=' ");
									 }break;
								 case LCOMPEG:
									 {
										 strcpy(aff_op," '==' ");
									 }break;
								 case LCOMPDIFF:
									 {
										 strcpy(aff_op," '!=' ");
									 }break;
								 case LOU:
									 {
										 strcpy(aff_op," '|' ");
									 }break;
								 case LET:
									 {
										 strcpy(aff_op," '&' ");
									 }break;
								 case LNON:
									 {
										 strcpy(aff_op," '!' ");
									 }break;
								 case LNEG:
									 {
										 strcpy(aff_op," '- unaire' ");
									 }break;
								 case LINC:
									 {
										 strcpy(aff_op," '++' ");
									 }break;
								 case LDEC:
									 {
										 strcpy(aff_op," '--' ");
									 }break;
							 }


/*printf("\n A");*/
							/* expression cote droit */
							if(exp->droit!=NULL)
								{

									rtyped=genere_recursif(exp->droit,0,bloc,NULL);
									if(etat_trace2==1) fprintf(file_code,"\n// TYPED = %s",rtyped);
									fprintf(file_code,"\n\tmov expr_d_%s_%s, expr_%s_%s",rtyped,bloc,rtyped,bloc);

							    }
							else rtyped=NULL;

							/* expression cote gauche */
							if((exp->operateur!=LINC)&&(exp->operateur!=LDEC)&&(exp->operateur!=LNEG)&&(exp->operateur!=LNON))
							   {
								   int ind_atome;
								 /*  printf("\n r");*/

								   /* sauve le contexte droit */

								   ind_atome=recherche_atome(rtyped);

								   if(ind_atome!=-1) /* c'est un atome */
									   {
								   			if(etat_trace2==1) fprintf(file_code,"\n//PUSH context expr_pile_%s_%s",rtyped,bloc);

								   			fprintf(file_code,"\n\treplace  expr_pile_%s_%s, expr_pile_%s_%s, expr_ptr_pile_%s_%s, expr_d_%s_%s"
								   		   			,rtyped,bloc
										  			,rtyped,bloc
										   			,rtyped,bloc
										   			,rtyped,bloc);
								   			fprintf(file_code,"\n\tset inc_%s, 1", bloc);
								   			fprintf(file_code,"\n\tadd expr_ptr_pile_%s_%s, expr_ptr_pile_%s_%s, inc_%s"
								   		   			,rtyped,bloc
										   			,rtyped,bloc
										   			,bloc);

						           			/* fin de sauvegarde */
										}
									else
										{
											if(etat_trace2==1) fprintf(file_code,"\n//No need to PUSH");
										}

								   rtypeg=genere_recursif(exp->gauche,0,bloc,NULL);

								  			 /* recuperation du contexte */


								    if(ind_atome!=-1) /* c'est un atome */
									   {
								   			if(etat_trace2==1) fprintf(file_code,"\n//POP context expr_pile_%s_%s",rtyped,bloc);

								   			fprintf(file_code,"\n\tset inc_%s, 1", bloc);
								   			fprintf(file_code,"\n\tsub expr_ptr_pile_%s_%s, expr_ptr_pile_%s_%s, inc_%s"
								   		   			,rtyped,bloc
										   			,rtyped,bloc
										   			,bloc);

								   			fprintf(file_code,"\n\tindex expr_d_%s_%s, expr_pile_%s_%s, expr_ptr_pile_%s_%s "
								   		   			,rtyped,bloc
										   			,rtyped,bloc
										   			,rtyped,bloc);
									    }
									else
										{
											if(etat_trace2==1) fprintf(file_code,"\n//No need to POP");
										}


								   if(etat_trace2==1) fprintf(file_code,"\n// TYPE = %s",rtypeg);

								   fprintf(file_code,"\n\tmov expr_g_%s_%s, expr_%s_%s",rtypeg,bloc,rtypeg,bloc);

								   if(etat_trace2==1) fprintf(file_code,"\n//%s TYPE VARIABLE d='%s' g='%s'",
														affiche,rtyped,rtypeg);

								   rtype=calcul_type_resultant(rtypeg,rtyped);
							  	   if(etat_trace2==1) fprintf(file_code,"\n// TYPE_RESULTANT %s",rtype);
							  }

							if(etat_trace2==1) fprintf(file_code,"\n//%s OPERATEUR %d/%s",affiche,exp->operateur,aff_op);

							switch(exp->operateur)
						 	 {
								 case LSHL:
									 {
										 int ind;
										 /* '<<'*/
										 fprintf(file_code,"\n\tshl expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s",rtype,bloc,rtypeg,bloc,rtyped,bloc);

										 ind=recherche_atome(rtype);
										 if((ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))
											{
												char libelle[200];

			 									sprintf(libelle,GC0090,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LSHR:
									 {
										 int ind;
										 /* '>>' */
										  fprintf(file_code,"\n\tshr expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s",rtype,bloc,rtypeg,bloc,rtyped,bloc);

										  ind=recherche_atome(rtype);
										  if((ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))
											{
												char libelle[200];

			 									sprintf(libelle,GC0100,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LMUL:
									 {
										 int ind;
										 /* '*' */
										  fprintf(file_code,"\n\tmul expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s",rtype,bloc,rtypeg,bloc,rtyped,bloc);

										  ind=recherche_atome(rtype);
										  if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0110,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LDIV:
									 {
										 int ind;
										 /* '/' */
										  fprintf(file_code,"\n\tdiv expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s",rtype,bloc,rtypeg,bloc,rtyped,bloc);

										  ind=recherche_atome(rtype);
										  if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0120,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LMODULO:
									 {
										 int ind;
										 /* '%' */
										  fprintf(file_code,"\n\tmod expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s",rtype,bloc,rtypeg,bloc,rtyped,bloc);

										  ind=recherche_atome(rtype);
										  if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0130,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LPLUS:
									 {
										 int ind;
										 /* '+' */
										  fprintf(file_code,"\n\tadd expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s",rtype,bloc,rtypeg,bloc,rtyped,bloc);

										  ind=recherche_atome(rtype);
										  if/*((ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))*/(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0140,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LMOINS:
									 {
										 int ind;
										 /* '-' */
										  fprintf(file_code,"\n\tsub expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s",rtype,bloc,rtypeg,bloc,rtyped,bloc);

										 ind=recherche_atome(rtype);
										 if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0150,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LCOMPET:
									 {
										 /* '&&' */
										  fprintf(file_code,"\n\tbrtst EQ, false_et_%d, expr_g_%s_%s",ind_et,rtypeg,bloc);
										  fprintf(file_code,"\n\tbrtst EQ, false_et_%d, expr_d_%s_%s",ind_et, rtyped,bloc);
										  fprintf(file_code,"\n\tset expr_byte_%s, 1",bloc);
										  fprintf(file_code,"\n\tjmp fin_test_et_%d",ind_et);
										  fprintf(file_code,"\nfalse_et_%d:",ind_et);
										  fprintf(file_code,"\n\tset expr_byte_%s, 0",bloc);
										  fprintf(file_code,"\nfin_test_et_%d:",ind_et);

										  rtype=(char *)&tab_atome[TBYTE][0];
										  ind_et++;
									 }break;
								 case LCOMPOU:
									 {
										 int ind;
										 /* '||' */
										  fprintf(file_code,"\n\tbrtst GT, true_ou_%d, expr_g_%s_%s",ind_ou,rtypeg,bloc);
										  fprintf(file_code,"\n\tbrtst GT, true_ou_%d, expr_d_%s_%s",ind_ou,rtyped,bloc);
										  fprintf(file_code,"\n\tset expr_byte_%s, 0",bloc);
										  fprintf(file_code,"\n\tjmp fin_test_ou_%d",ind_ou);
										  fprintf(file_code,"\ntrue_ou_%d:",ind_ou);
										  fprintf(file_code,"\n\tset expr_byte_%s, 1",bloc);
										  fprintf(file_code,"\nfin_test_ou_%d:",ind_ou);

										  rtype=(char *)&tab_atome[TBYTE][0];
										  ind_ou++;
									 }break;
								 case LCOMPINF:
									 {
										 int ind;
										 /* '<' */

										 ind=recherche_atome(rtype);
										 if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0160,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}

										  /* correctif */
										  cast_type(bloc,&rtypeg,&rtyped,rtype);
										  /* correctif */

										  fprintf(file_code,"\n\tcmp LT, expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s","byte",bloc,rtypeg,bloc,rtyped,bloc);
										  rtype=(char *)&tab_atome[TBYTE][0];
									 }break;
								 case LCOMPSUP:
									 {
										 int ind;
										 /* '>' */
										 ind=recherche_atome(rtype);
										 if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0170,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}

										  /* correctif */
										  cast_type(bloc,&rtypeg,&rtyped,rtype);
										  /* correctif */

										  fprintf(file_code,"\n\tcmp GT, expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s","byte",bloc,rtypeg,bloc,rtyped,bloc);
										  rtype=(char *)&tab_atome[TBYTE][0];
									 }break;
								 case LCOMPINFEG:
									 {
										 int ind;
										 /* '<=' */
										 ind=recherche_atome(rtype);
										 if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0180,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}

										  /* correctif */
										  cast_type(bloc,&rtypeg,&rtyped,rtype);
										  /* correctif */

										  fprintf(file_code,"\n\tcmp LTEQ, expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s","byte",bloc,rtypeg,bloc,rtyped,bloc);
										  rtype=(char *)&tab_atome[TBYTE][0];
									 }break;
								 case LCOMPSUPEG:
									 {
										 int ind;
										 /* '>=' */
										 ind=recherche_atome(rtype);
										 if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0190,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}

										  /* correctif */
										  cast_type(bloc,&rtypeg,&rtyped,rtype);
										  /* correctif */

										  fprintf(file_code,"\n\tcmp GTEQ, expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s","byte",bloc,rtypeg,bloc,rtyped,bloc);
										  rtype=(char *)&tab_atome[TBYTE][0];
									 }break;
								 case LCOMPEG:
									 {
										 int ind;
										 /* '==' */

										   /* correctif */
										  cast_type(bloc,&rtypeg,&rtyped,rtype);
										  /* correctif */


										 fprintf(file_code,"\n\tcmp EQ, expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s","byte",bloc,rtypeg,bloc,rtyped,bloc);
										 rtype=(char *)&tab_atome[TBYTE][0];
									 }break;
								 case LCOMPDIFF:
									 {
										 int ind;
										 /* '!=' */

										   /* correctif */
										  cast_type(bloc,&rtypeg,&rtyped,rtype);
										  /* correctif */

										  fprintf(file_code,"\n\tcmp NEQ, expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s","byte",bloc,rtypeg,bloc,rtyped,bloc);
										  rtype=(char *)&tab_atome[TBYTE][0];
									 }break;
								 case LOU:
									 {
										 int ind;
										 /* '|' */
										  fprintf(file_code,"\n\tor expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s",rtype,bloc,rtypeg,bloc,rtyped,bloc);

										 ind=recherche_atome(rtype);
										 if((ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))
											{
												char libelle[200];

			 									sprintf(libelle,GC0200,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LET:
									 {
										 int ind;
										 /* '&' */
										 fprintf(file_code,"\n\tand expr_%s_%s, expr_g_%s_%s, expr_d_%s_%s",rtype,bloc,rtypeg,bloc,rtyped,bloc);

										 ind=recherche_atome(rtype);
										 if((ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))
											{
												char libelle[200];

			 									sprintf(libelle,GC0210,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LNON:
									 {
										 int ind;
										 /* '!' */


										 rtypeg=genere_recursif(exp->gauche,0,bloc,NULL);

										 ind=recherche_atome(rtypeg);

										 if((ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))
											{
												char libelle[200];

			 									sprintf(libelle,GC0220,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}

										 rtype=rtypeg;

										 fprintf(file_code,"\n\tnot expr_%s_%s, expr_%s_%s",rtype,bloc,rtypeg,bloc);

									 }break;
								  case LNEG:
									 {
										 int ind;
										 /* '- unaire' */

										 rtypeg=genere_recursif(exp->gauche,0,bloc,NULL);

										 ind=recherche_atome(rtypeg);

										 if((ind!=TSBYTE)&&(ind!=TSWORD)&&(ind!=TSDWORD)&&
											(ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))
											{
												char libelle[200];

			 									sprintf(libelle,GC0230,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}

										 if(ind==TBYTE)  		rtype=(char *)&tab_atome[/*TSBYTE*//*patch*/ TSWORD][0];
										 else if (ind==TWORD)   rtype=(char *)&tab_atome[/*TSWORD*//*patch*/ TSDWORD][0];
										 else if (ind==TDWORD)  rtype=(char *)&tab_atome[TSDWORD][0];
										 else
										 	rtype=rtypeg;

										 /*printf("\n\tneg expr_%s_%s, expr_g_%s_%s",rtype,bloc,rtypeg,bloc);*/

										 fprintf(file_code,"\n\tneg expr_%s_%s, expr_%s_%s",rtype,bloc,rtypeg,bloc);

									 }break;
								 case LINC:
									 {
										 int ind;
										 /* '++' */
										  rtype=genere_recursif(exp->gauche,2,bloc,NULL);

							  	  		  if(etat_trace2==1) fprintf(file_code,"\n// TYPE_RESULTANT %s",rtype);

										  ind=recherche_atome(rtype);
										  if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0240,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
								 case LDEC:
									 {
										 int ind;
										 /* '--' */
										  rtype=genere_recursif(exp->gauche,3,bloc,NULL);

										 if(etat_trace2==1) fprintf(file_code,"\n// TYPE_RESULTANT %s",rtype);

										 ind=recherche_atome(rtype);
										 if(ind==-1)
											{
												char libelle[200];

			 									sprintf(libelle,GC0250,
															 	bloc,rtype);
		 										message_erreur(libelle);
											}
									 }break;
							 }
						}break;
					case EXP_FONCTION:
						{
							int i;
							int j;
							VARIABLE_GLOBALE *parametres;
							char bloc_mod[PROF_BLOC+1];
							char nom_variable_parametre[MAX_PARAMETRE][MAX_IDENT];

							/*monte();*/

							if(etat_trace2==1) fprintf(file_code,"\n//%s FONCTION %s nb ARG = %d",
								affiche,
								exp->feuille.sfonction.fonction,
								exp->feuille.sfonction.nb_argument);

							for(j=0;j<nb_fonction;j++)
								if(strcmp(tab_fonction[j].ident_fonction,exp->feuille.sfonction.fonction)==0) break;

							if(j==nb_fonction)
								{
										char libelle[200];

			 							sprintf(libelle,GC0260,
														 bloc,exp->feuille.sfonction.fonction);
		 								message_erreur(libelle);
								}

/* generation automatique de semaphore */

							if(etat_sema==1)
								fprintf(file_code,"\n\tacquire mutex_%s // acquire the function",exp->feuille.sfonction.fonction);

							if(exp->feuille.sfonction.nb_argument!=tab_fonction[j].nb_parametre)
								{
									char libelle[200];

			 						sprintf(libelle,GC0270,
														 bloc,exp->feuille.sfonction.fonction,
														 exp->feuille.sfonction.nb_argument,
														 tab_fonction[j].nb_parametre);
		 							message_erreur(libelle);
								}

							parametres=(VARIABLE_GLOBALE *)((char *)tab_fonction[j].parametres-((exp->feuille.sfonction.nb_argument-1)*(sizeof(VARIABLE_GLOBALE))));

							for(i=0;i<exp->feuille.sfonction.nb_argument;i++)
								{
									char *typer;

									if(etat_trace2==1) fprintf(file_code,"\n//%s : argument %d",affiche,i);

									rtype=genere_recursif(exp->feuille.sfonction.argument_ptr[i],0,bloc,NULL);

									if(parametres[i].modify==1)
										{
											if(exp->feuille.sfonction.argument_ptr[i]->type==EXP_VARIABLE)
												 strcpy((char *)&nom_variable_parametre[i][0],derniere_variable);
											else
											     strcpy((char *)&nom_variable_parametre[i][0],"not a variable");
									    }

									if(etat_trace2==1) fprintf(file_code,"\n//%s : argument %d ident param '%s'  type '%s' vs '%s'",
										affiche,i,parametres[i].ident,
										parametres[i].type_variable_ptr->type,
										rtype);

									typer=calcul_type_resultant(convertit_type_gen(parametres[i].type_variable_ptr->type,0),rtype);

									if(recherche_atome(rtype)==-1) /* ce n'est pas un atome */
									 {
										int parm_tab;

										if(parametres[i].type_pointeur==POINTEUR)
											parm_tab=1;
										else
											parm_tab=0;


						/* printf("\n -----> %s %s %d \n",convertit_type_gen(parametres[i].type_variable_ptr->type,parm_tab),rtype,parm_tab); */


										if(strcmp(convertit_type_gen(parametres[i].type_variable_ptr->type,parm_tab),rtype)!=0)
									 	 {
											char libelle[200];

			 								sprintf(libelle,GC0280,
														 bloc,
														 exp->feuille.sfonction.fonction,
														 parametres[i].type_variable_ptr->type,
														 rtype,
														 parametres[i].ident);

		 									message_erreur(libelle);
									 	}
									}

								   if(parametres[i].type_pointeur!=PASPOINTEUR) /* tableau */
									   { /* patch 20/08 */
										if(strcmp(rtype,"byte_tab")==0)
										 fprintf(file_code,"\n\tmov %s_%s, expr_%s_%s // %s ",/*_tab vire */
								   			exp->feuille.sfonction.fonction,
											parametres[i].ident,
											rtype,
											bloc,
											typer);
										else
										 fprintf(file_code,"\n\tmov %s_%s, expr_%s_tab_%s // %s ",/*_tab ajoute */
								   			exp->feuille.sfonction.fonction,
											parametres[i].ident,
											rtype,
											bloc,
											typer);
									    }
								   else	/* pas tableau */
								   		fprintf(file_code,"\n\tmov %s_%s, expr_%s_%s",
								   			exp->feuille.sfonction.fonction,
											parametres[i].ident,
											rtype,
											bloc);
								}

							if(etat_trace2==1) fprintf(file_code,"\n//%s : appel la subroutine '%s'",affiche,exp->feuille.sfonction.fonction);
							fprintf(file_code,"\n\tcall %s",exp->feuille.sfonction.fonction);

							for(i=0;i<exp->feuille.sfonction.nb_argument;i++)
								{
									if(parametres[i].modify==1)
										{

											if(exp->feuille.sfonction.argument_ptr[i]->type!=EXP_VARIABLE)
												 {
													char libelle[200];

			 										sprintf(libelle,GC0290,
														 bloc,
														 exp->feuille.sfonction.fonction,
														 parametres[i].type_variable_ptr->type,
														 rtype,
														 parametres[i].ident);

		 											message_erreur(libelle);
												 }

							/*if(strcmp(exp->feuille.sfonction.argument_ptr[i]->feuille.svariable.variable_ptr->bloc,"0")==0)
							/*s*//*printf(/*nom_variable,*//**//*"\nmod globale_%s",exp->feuille.sfonction.argument_ptr[i]->feuille.svariable.variable_ptr->ident);
							else
		 					/*s*//*printf(/*nom_variable,*//*"\nmod %s_%s",exp->feuille.sfonction.argument_ptr[i]->feuille.svariable.variable_ptr->bloc,
																 exp->feuille.sfonction.argument_ptr[i]->feuille.svariable.variable_ptr->ident);*/

											if(strcmp(exp->feuille.sfonction.argument_ptr[i]->feuille.svariable.variable_ptr->bloc,"0")==0)
							 					sprintf(bloc_mod,"globale");
											else
		 					 					sprintf(bloc_mod,"%s",exp->feuille.sfonction.argument_ptr[i]->feuille.svariable.variable_ptr->bloc);

											/*fprintf(file_code,"\n\tmov %s_%s, %s_%s",
											 		 bloc_mod,
											 		 exp->feuille.sfonction.argument_ptr[i]->feuille.svariable.ident_variable,
								   					 exp->feuille.sfonction.fonction,
													 parametres[i].ident);*/

											fprintf(file_code,"\n\tmov %s, %s_%s",
											 		 (char *)&nom_variable_parametre[i][0],
								   					 exp->feuille.sfonction.fonction,
													 parametres[i].ident);

											/*printf("\n 	%s %s<=>%s",
													bloc_mod,
													exp->feuille.sfonction.argument_ptr[i]->feuille.svariable.ident_variable,
													(char *)&nom_variable_parametre[i][0]);*/
										}
								}

							if(etat_trace2==1)
							   {
								   if(strcmp(tab_fonction[j].type_variable_retournee_ptr->type,"void")!=0)
						   		 		fprintf(file_code,"\n//TYPE RETOURNEE '%s'",
											tab_fonction[j].type_variable_retournee_ptr->type);
									else
										fprintf(file_code,"\n//TYPE RETOURNEE VOID");
							   }

							if(strcmp(tab_fonction[j].type_variable_retournee_ptr->type,"void")!=0)
								{
									rtype=convertit_type_gen(tab_fonction[j].type_variable_retournee_ptr->type,0);
									fprintf(file_code,"\n\tmov expr_%s_%s, expr_%s_%s",
													 rtype,
													 bloc,
													 rtype,
											 		 tab_fonction[j].ident_fonction);
								}
							else
								rtype=tab_fonction[j].type_variable_retournee_ptr->type;

/* generation automatique de semaphore */

							if(etat_sema==1)
								fprintf(file_code,"\n\trelease mutex_%s // release the function",exp->feuille.sfonction.fonction);

							/*descend();*/
						}break;
		  }

	descend();

	/*printf("\n retour = '%s'",rtype);*/

	return(rtype);
 }


void genere_instruction(INSTRUCTION *,char *);


/* genere les do while */

void genere_inst_do_while(INSTRUCTION *inst,char *bloc)
 {
	 SEXPRESSION *exp;
	 INSTRUCTION *inst_r;
	 char *rtype;

	 monte();
	 push_boucle(inst);

	 exp=inst->instruction.sdo_repeat.expression_ptr;
	 inst_r=inst->instruction.sdo_repeat.corps;

	 if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION DO LISTEINST WHILE(EXP) ", affiche);

	 fprintf(file_code,"\n%s_do_while_%d:",inst->bloc,inst->index);

	 if(etat_trace2==1) fprintf(file_code,"\n//%s DEBUT CORPS DO WHILE ",affiche);

	 genere_instruction(inst_r,bloc);

	 if(etat_trace2==1) fprintf(file_code,"\n//%s FIN CORPS DO WHILE ",affiche);

	 if(exp!=NULL)
		 {
	 		if(etat_trace2==1) fprintf(file_code,"\n//%s EVALUATION CONDITION ", affiche);

	 		rtype=genere_recursif(exp,0,bloc,NULL);

			if(etat_trace2==1) fprintf(file_code,"\n//%s FIN EVALUATION CONDITION %s", affiche,rtype);


			if(recherche_atome(rtype)==-1)
				{
					char libelle[200];

			 		sprintf(libelle,GC0300,
										bloc,rtype);
		 			message_erreur(libelle);
				}

			fprintf(file_code,"\n\tbrcmp GT, %s_do_while_%d, expr_%s_%s, 0",inst->bloc,inst->index,rtype,bloc);
			/*printf("\n\tbrcmp GT, %s_do_while_%d, expr_%s_%s, 0",inst->bloc,inst->index,rtype,bloc);*/
		 }
	 else
		 {
			if(etat_trace2==1) fprintf(file_code,"\n//%s EXPRESSION VIDE ",affiche);
			fprintf(file_code,"\n\tset expr_%s_%s, 0","word",bloc);
			fprintf(file_code,"\n\tbrcmp GT, %s_do_while_%d, expr_%s_%s, 0",inst->bloc,inst->index,"word",bloc);
		 }

	 fprintf(file_code,"\nbreak_%s_do_while_%d:",inst->bloc,inst->index);

	 pop_boucle();
	 descend();
 }

/* affiche les for */

void genere_inst_for(INSTRUCTION *inst,char *bloc)
 {
	 SEXPRESSION *exp1;
	 SAFFECTATION *aff1,*aff2;
	 INSTRUCTION *inst_r;
	 char *rtype,*rtype1,*rtype2;

	 monte();
	 push_boucle(inst);

	 aff1=inst->instruction.sfor.argument_init_ptr;
	 exp1=inst->instruction.sfor.expression_ptr;
	 aff2=inst->instruction.sfor.argument_increment_ptr;
	 inst_r=inst->instruction.sfor.corps_for;

	 if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION FOR(AFF1;EXP;INST1)LISTINST ", affiche);
	 if(etat_trace2==1) fprintf(file_code,"\n//%s INIT ", affiche);


  if(aff1!=NULL)
   {
	 if(aff1->type_affectation==AFF_EXP)
	   {
		    if(etat_trace2==1) fprintf(file_code,"\n//%s = ",affiche);

	 		rtype1=genere_recursif(aff1->valeur_affectee,0,bloc,NULL);

			fprintf(file_code,"\n\tmov expr_aff_%s_%s, expr_%s_%s",rtype1,bloc,rtype1,bloc);

		    rtype2=genere_recursif(aff1->variable,1,bloc,rtype1);

			rtype=calcul_type_resultant(rtype1,rtype2);

			if(recherche_atome(rtype)==-1)
				{
					char libelle[200];

			 		sprintf(libelle,GC0310,
										bloc,rtype);
		 			message_erreur(libelle);
				}

	   }
	 else if(aff1->type_affectation==AFF_INC)
		 {
		 	if(etat_trace2==1) fprintf(file_code,"\n//%s ++ INCREMENT ",affiche);
			genere_recursif(aff1->variable,2,bloc,NULL);
		 }
	 else if(aff1->type_affectation==AFF_DEC)
		 {
		 	if(etat_trace2==1) fprintf(file_code,"\n//%s -- DECREMENT ",affiche);
			genere_recursif(aff1->variable,3,bloc,NULL);
	 	 }
   }
  else
   {
	  if(etat_trace2==1) fprintf(file_code,"\n//%s AFF1 VIDE ",affiche);
   }

	 fprintf(file_code,"\n\tjmp eval_cond_%s_for_%d",inst->bloc,inst->index);

	 fprintf(file_code,"\n%s_for_%d:",inst->bloc,inst->index);

	 if(etat_trace2==1) fprintf(file_code,"\n//%s DEBUT CODE CORPS DU FOR ", affiche);

	 genere_instruction(inst_r,bloc);

	 if(etat_trace2==1) fprintf(file_code,"\n//%s FIN CODE CORPS DU FOR ", affiche);

	 fprintf(file_code,"\ncontinue_%s_for_%d:",inst->bloc,inst->index);

	 if(etat_trace2==1) fprintf(file_code,"\n//%s EVOLUTION VARIABLE DU FOR", affiche);

  if(aff2!=NULL)
   {
	 if(aff2->type_affectation==AFF_EXP)
	   {
		    if(etat_trace2==1) fprintf(file_code,"\n//%s = ",affiche);

	 		rtype1=genere_recursif(aff2->valeur_affectee,0,bloc,NULL);

			fprintf(file_code,"\n\tmov expr_aff_%s_%s, expr_%s_%s",rtype1,bloc,rtype1,bloc);

			rtype2=genere_recursif(aff2->variable,1,bloc,rtype1);

			rtype=calcul_type_resultant(rtype1,rtype2);

			if(recherche_atome(rtype)==-1)
				{
					char libelle[200];

			 		sprintf(libelle,GC0320,
										bloc,rtype);
		 			message_erreur(libelle);
				}
	   }
	 else if(aff2->type_affectation==AFF_INC)
		 {
		 	if(etat_trace2==1) fprintf(file_code,"\n//%s ++ INCREMENT ",affiche);
			genere_recursif(aff2->variable,2,bloc,NULL);
		 }
	 else if(aff2->type_affectation==AFF_DEC)
		 {
		 	if(etat_trace2==1) fprintf(file_code,"\n//%s -- DECREMENT ",affiche);
			genere_recursif(aff2->variable,3,bloc,NULL);
		 }
    }
  else
	{
		  if(etat_trace2==1) fprintf(file_code,"\n//%s AFF2 VIDE ",affiche);
	}

	 if(etat_trace2==1) fprintf(file_code,"\n//%s EVALUATION CONDITION ", affiche);

 	 fprintf(file_code,"\neval_cond_%s_for_%d:",inst->bloc,inst->index);

  if(exp1!=NULL)
   {
	 rtype=genere_recursif(exp1,0,bloc,NULL);
	 if(recherche_atome(rtype)==-1)
		{
			char libelle[200];

			sprintf(libelle,GC0330,
										bloc,rtype);
		 	message_erreur(libelle);
		}

	 if(etat_trace2==1) fprintf(file_code,"\n//%s SAUT si EXPRESSION VRAI ", affiche);

	 fprintf(file_code,"\n\tbrcmp GT, %s_for_%d, expr_%s_%s, 0",inst->bloc,inst->index,rtype,bloc);
   }
  else
   {
	   	if(etat_trace2==1) fprintf(file_code,"\n//%s EXPRESSION VIDE ", affiche);
		fprintf(file_code,"\n\tjmp %s_for_%d",inst->bloc,inst->index);
   }

	 fprintf(file_code,"\nbreak_%s_for_%d:",inst->bloc,inst->index);

	 pop_boucle();
	 descend();
 }


 /* genere les if */

void genere_inst_if(INSTRUCTION *inst,char *bloc)
 {
	 SEXPRESSION *exp;
	 INSTRUCTION *inst_then,*inst_else,*inst_r;
	 int type_if;
	 char *rtype;

	 monte();

	 exp=inst->instruction.sif.argument;
	 inst_then=inst->instruction.sif.corps_if;
	 inst_else=inst->instruction.sif.corps_else;
	 type_if=inst->instruction.sif.selse;

	 if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION IF ", affiche);

	 rtype=genere_recursif(exp,0,bloc,NULL);

	 if(recherche_atome(rtype)==-1)
		{
			char libelle[200];

			sprintf(libelle,GC0340,
										bloc,rtype);
		 	message_erreur(libelle);
		}

	 if(type_if==0)
	 	fprintf(file_code,"\n\tbrcmp EQ, end_%s_if_%d, expr_%s_%s, 0",inst->bloc,inst->index,rtype,bloc);
	 else
		fprintf(file_code,"\n\tbrcmp EQ, else_%s_if_%d, expr_%s_%s, 0",inst->bloc,inst->index,rtype,bloc);

	 if(etat_trace2==1) fprintf(file_code,"\n//%s THEN ",affiche);

	 genere_instruction(inst_then,bloc);

	 if(type_if==1)
		 {

			    fprintf(file_code,"\n\tjmp end_%s_if_%d",inst->bloc,inst->index);

				fprintf(file_code,"\nelse_%s_if_%d:",inst->bloc,inst->index);

				if(etat_trace2==1) fprintf(file_code,"\n//%s ELSE", affiche);

	 			genere_instruction(inst_else,bloc);

		 }

	 fprintf(file_code,"\nend_%s_if_%d:",inst->bloc,inst->index);

	 descend();
 }

/* fonction de recherche de label pour goto */

int rechercher_index_label(char *bloc,char *label)
 {
	 int i;
	 int nb;
	 int index;

	 nb=0;

	 for(i=0;i<nb_instruction;i++)
		 {
			 if(strcmp(tab_instruction[i].bloc,bloc)==0)
				 {
					 if(tab_instruction[i].type_instruction==INST_LABEL)
						 {
							 if(strcmp(tab_instruction[i].instruction.slabel,label)==0)
								 {
									 index=i;
									 nb++;
							     }
						 }
				 }
		 }

	 if(nb==0)
		 {
			 char libelle[200];

			 sprintf(libelle,GC0350,label,bloc);
		 	 message_erreur(libelle);
		 }

	  if(nb>1)
		 {
			 char libelle[200];

			 sprintf(libelle,GC0360,label,bloc);
		 	 message_erreur(libelle);
		 }

	 return(index);
 }


/* fonction de recherche de label pour goto */

int rechercher_index_mutex(char *ident)
 {
	 int i;

	 for(i=0;i<nb_mutex;i++)
			 if(strcmp(tab_mutex[i].ident,ident)==0) break;

	 if(nb_mutex==i)
		 return(-1);
	 else
	 	return(i);
 }

/* fonction de recherche d'une tache */

int rechercher_tache(char *label,char *bloc)
 {
	 int i;

	 for(i=0;i<nb_tache;i++)
		 {
			 if(strcmp(label,tab_tache[i].ident_tache)==0) break;
		 }

	 if(i==nb_tache)
		 {
			 char libelle[200];

			 sprintf(libelle,GC0370,label,bloc);
		 	 message_erreur(libelle);
		 }

	 return(i);
 }

/* fonction de generation des instructions */

void genere_instruction(INSTRUCTION *inst,char *bloc)
  {
	  char *rtype,*rtype1,*rtype2;

	  monte();


	/*  printf("\n instruction %s %d",bloc,inst->type_instruction);*/

	  if(inst==NULL)
	   {
			  /*if(traceaff==1) printf("\n%s FEUILLE ",affiche);*/
       }
	  else
	   {

		   if(etat_trace2==1) fprintf(file_code,"\n//\n//\n//%s Index instruction =%d %s", affiche,((char *)inst-(char *)&tab_instruction[0])/sizeof(INSTRUCTION),inst->bloc);

		   switch(inst->type_instruction)
		     {
				case INST_INLINE:
				   {
					   if(etat_trace2==1) fprintf(file_code,"\n//%s INLINE ", affiche);
					   fprintf(file_code,"\n\t%s", inst->instruction.sinline);
				   }break;
				case INST_IF :
					{
							 if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION IF ", affiche);

							 genere_inst_if(inst,bloc);
					}break;
				case INST_FOR :
					{
						 	 if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION FOR ", affiche);
							 genere_inst_for(inst,bloc);
					}break;
				case INST_DO_REPEAT :
					{
							if(etat_trace2==1) fprintf(file_code,"\n//%s DO WHILE ", affiche);
							genere_inst_do_while(inst,bloc);
					}break;
				case INST_SWITCH :
					{
						int i;

						if(etat_trace2==1) fprintf(file_code,"\n//%s__________________________________________________________________________________",affiche);
						if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION SWITCH ",affiche);
						if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION EXPRESSION ",affiche);

						if(inst->instruction.sswitch.nb_case>0)
							{
								rtype=genere_recursif(inst->instruction.sswitch.expression,0,bloc,NULL);

	 							if(recherche_atome(rtype)==-1)
									{
										char libelle[200];

										sprintf(libelle,GC0380,
														bloc,rtype);
									 	message_erreur(libelle);
									}

								fprintf(file_code,"\n\tmov expr_switch_%d, expr_%s_%s",inst->index,rtype,bloc);
								fprintf(file_code,"\n//%s CORPS SWITCH NB CASE = %d ",affiche,inst->instruction.sswitch.nb_case);
							}
						else if(etat_trace2==1) fprintf(file_code,"\n//%s CORPS SWITCH VIDE",affiche);

						for(i=0;i<inst->instruction.sswitch.nb_case;i++)
		 				 {
							int j;

							monte();

							if(etat_trace2==1) fprintf(file_code,"\n//%s case/default %d",affiche,i);

							if(inst->instruction.sswitch.type_case[i]==TYPE_CASE_CASE)
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s CASE ",affiche);
								}
							else
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s DEFAULT ",affiche);
								}

							monte();

							if(inst->instruction.sswitch.expression_case[i]==NULL)
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s EXPRESSION VIDE",affiche);
							    }
							else
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s EXPRESSION CASE #%d",affiche,i+1);
									rtype1=genere_recursif(inst->instruction.sswitch.expression_case[i],0,bloc,NULL);

									if(recherche_atome(rtype1)==-1)
										{
											char libelle[200];

											sprintf(libelle,GC0390,
														bloc,rtype1);
									 		message_erreur(libelle);
										}
/* correctif 14-04-07 */
									fprintf(file_code,"\n\tmov expr_sdword_%s, expr_%s_%s ",
											bloc,rtype1,bloc);
/* correctif 14-04-07 */
									fprintf(file_code,"\n\tbrcmp NEQ, %s_switch_%d_case_%d, expr_switch_%d, expr_%s_%s ",
											inst->bloc,inst->index,i+1,inst->index,"sdword",bloc);
								}

							descend();

							if(inst->instruction.sswitch.cases[i]==NULL)
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION VIDE",affiche);
									for(j=i+1;j<inst->instruction.sswitch.nb_case;j++)
										if(inst->instruction.sswitch.cases[j]!=NULL) break;
									fprintf(file_code,"\n\tjmp bloc_%s_switch_%d_case_%d",inst->bloc,inst->index,j);
								}
							else
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION DU CASE #%d",affiche,i+1);
									fprintf(file_code,"\nbloc_%s_switch_%d_case_%d:",inst->bloc,inst->index,i);
									genere_instruction(inst->instruction.sswitch.cases[i],bloc);
								}

	  						if(inst->instruction.sswitch.break_or_not[i]==1)
								 {
									if(etat_trace2==1) fprintf(file_code,"\n//%s BREAK",affiche);

									fprintf(file_code,"\n\tjmp %s_switch_%d_case_%d",inst->bloc,inst->index,inst->instruction.sswitch.nb_case);
								 }
							else
								if(etat_trace2==1) fprintf(file_code,"\n//%s PAS DE BREAK",affiche);

							if((inst->instruction.sswitch.type_case[i]==TYPE_CASE_DEFAULT)&&
							   (inst->instruction.sswitch.break_or_not[i]==0))
								{
									fprintf(file_code,"\n\tjmp %s_switch_%d_case_%d",inst->bloc,inst->index,inst->instruction.sswitch.nb_case);
								}

							descend();

							fprintf(file_code,"\n%s_switch_%d_case_%d:",inst->bloc,inst->index,i+1);
						 }

						/*fprintf(file_code,"\n%s_switch_%d_case_%d:",inst->bloc,inst->index,inst->instruction.sswitch.nb_case);*/

						if(inst->instruction.sswitch.nb_case==0)  {if(etat_trace2==1) fprintf(file_code,"\n//%s CORPS SWITCH VIDE ",affiche);}
	 					if(etat_trace2==1) fprintf(file_code,"\n//%s__________________________________________________________________________________",affiche);

					}break;
				case INST_LABEL :
					{
							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION LABEL '%s' ", affiche,inst->instruction.slabel);
							fprintf(file_code,"\n%s_switch_%d_label_%s:",inst->bloc,inst->index,inst->instruction.slabel);
					}break;
				case INST_GOTO :
					{
							int index;

							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION GOTO '%s'", affiche,inst->instruction.sgoto);
							index=rechercher_index_label(inst->bloc,inst->instruction.sgoto);
							fprintf(file_code,"\n\tjmp %s_switch_%d_label_%s",inst->bloc,index,inst->instruction.sgoto);
					}break;
				case INST_ACQUIRE :
					{
							int index;

							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION ACQUIRE '%s'", affiche,inst->instruction.smutex_acquire);

							index=rechercher_index_mutex(inst->instruction.smutex_acquire);

							if(index==-1)
								{
									char libelle[200];

									sprintf(libelle,GC0400,
														inst->bloc,inst->instruction.smutex_acquire);
									message_erreur(libelle);
								}

							fprintf(file_code,"\n\tacquire %s",inst->instruction.smutex_acquire);
					}break;
				case INST_RELEASE :
					{
							int index;

							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION RELEASE '%s'", affiche,inst->instruction.smutex_release);

							index=rechercher_index_mutex(inst->instruction.smutex_release);

							if(index==-1)
								{
									char libelle[200];

									sprintf(libelle,GC0410,
														inst->bloc,inst->instruction.smutex_release);
								    message_erreur(libelle);
								}

							fprintf(file_code,"\n\trelease %s",inst->instruction.smutex_release);
					}break;



				case INST_ARRSIZE:
					{
							int index_label;
							int index_size;
							char prefixe_label[MAX_IDENT];
							char prefixe_size[MAX_IDENT];

							index_label=recherche_variable(inst->instruction.sarrsize.label,inst->bloc);
							index_size =recherche_variable(inst->instruction.sarrsize.size,inst->bloc);

							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION ARRSIZE label='%s' size='%s'", affiche,
								inst->instruction.sarrsize.label,inst->instruction.sarrsize.size);

							if(strcmp(program.vg[index_label].bloc,"0")==0)
									strcpy(prefixe_label,"globale");
							else
									strcpy(prefixe_label,program.vg[index_label].bloc);

							if(strcmp(program.vg[index_size].bloc,"0")==0)
									strcpy(prefixe_size,"globale");
							else
									strcpy(prefixe_size,program.vg[index_size].bloc);

							fprintf(file_code,"\n\tarrsize %s_%s, %s_%s",
								prefixe_size,inst->instruction.sarrsize.size,
								prefixe_label,inst->instruction.sarrsize.label);

					}break;
				case INST_ARRINIT:
					{
							SEXPRESSION *expression_value_ptr;
							SEXPRESSION *expression_size_ptr;
							int index_label;
							char prefixe_label[MAX_IDENT];
							char *rtype_value,*rtype_size;
							int  ind;

	 						expression_value_ptr=inst->instruction.sarrinit.expression_value_ptr;
							expression_size_ptr=inst->instruction.sarrinit.expression_size_ptr;

							index_label=recherche_variable(inst->instruction.sarrinit.label,inst->bloc);

							if(strcmp(program.vg[index_label].bloc,"0")==0)
									strcpy(prefixe_label,"globale");
							else
									strcpy(prefixe_label,program.vg[index_label].bloc);

							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION ARRINIT label='%s'", affiche,
								inst->instruction.sarrinit.label);

							rtype_value=genere_recursif(expression_value_ptr,0,bloc,NULL);
							fprintf(file_code,"\n\tmov %s_%s_%s, %s_%s_%s",
												   "value",rtype_value,bloc,
												   "expr", rtype_value,bloc);

							rtype_size=genere_recursif(expression_size_ptr,0,bloc,NULL);

/* contrôle de la comptabilité du type à réaliser */
							ind=recherche_atome(rtype_size);
							if((ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))
							  {
									char libelle[200];

			 						sprintf(libelle,GC0420,
									 	bloc,rtype_size);
		 							message_erreur(libelle);
							  }

							fprintf(file_code,"\n\tmov %s_%s_%s, %s_%s_%s",
												   "size","word",bloc,
												   "expr",rtype_size,bloc);

							fprintf(file_code,"\n\tarrinit %s_%s, %s_%s_%s, %s_%s_%s",
								prefixe_label,inst->instruction.sarrinit.label,
								"value",rtype_value,bloc,
								"size","word",bloc);

					}break;
				case INST_ARRSUBSET:
					{
							int index_src;
							int index_dst;
							char prefixe_src[MAX_IDENT];
							char prefixe_dst[MAX_IDENT];
							SEXPRESSION *expression_index_ptr;
							SEXPRESSION *expression_length_ptr;
							char *rtype_index,*rtype_length;
							int ind;

							expression_index_ptr=inst->instruction.sarrsubset.expression_index_ptr;
							expression_length_ptr=inst->instruction.sarrsubset.expression_length_ptr;

							index_src=recherche_variable(inst->instruction.sarrsubset.label_src,inst->bloc);
							index_dst=recherche_variable(inst->instruction.sarrsubset.label_dst,inst->bloc);

							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION ARRSUBSET src ='%s' dst='%s'", affiche,
								inst->instruction.sarrsubset.label_src,inst->instruction.sarrsubset.label_dst);

							if(strcmp(program.vg[index_src].bloc,"0")==0)
									strcpy(prefixe_src,"globale");
							else
									strcpy(prefixe_src,program.vg[index_src].bloc);

							if(strcmp(program.vg[index_dst].bloc,"0")==0)
									strcpy(prefixe_dst,"globale");
							else
									strcpy(prefixe_dst,program.vg[index_dst].bloc);

							rtype_index=genere_recursif(expression_index_ptr,0,bloc,NULL);
/* contrôle de la comptabilité du type à réaliser */
							ind=recherche_atome(rtype_index);
							if((ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))
							  {
									char libelle[200];

			 						sprintf(libelle,GC0430,
									 	bloc,rtype_index);
		 							message_erreur(libelle);
							  }

							fprintf(file_code,"\n\tmov %s_%s_%s, %s_%s_%s",
												   "index","word",bloc,
												   "expr", rtype_index,bloc);

							rtype_length=genere_recursif(expression_length_ptr,0,bloc,NULL);
/* contrôle de la comptabilité du type à réaliser */
							ind=recherche_atome(rtype_length);
							if((ind!=TBYTE)&&(ind!=TWORD)&&(ind!=TDWORD))
							  {
									char libelle[200];

			 						sprintf(libelle,GC0440,
									 	bloc,rtype_length);
		 							message_erreur(libelle);
							  }

							fprintf(file_code,"\n\tmov %s_%s_%s, %s_%s_%s",
												   "length","word",bloc,
												   "expr", rtype_length,bloc);

							fprintf(file_code,"\n\tarrsubset %s_%s, %s_%s, %s_%s_%s, %s_%s_%s",
								prefixe_dst,inst->instruction.sarrsubset.label_dst,
								prefixe_src,inst->instruction.sarrsubset.label_src,
								"index","word",bloc,
								"length","word",bloc);

					}break;
				case INST_ARRBUILD:
					{
							int i;

							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION ARRBUILD %d", affiche,
								inst->instruction.sarrbuild.nb_tab);

							fprintf(file_code,"\n\tarrbuild ");

							for(i=0;i<inst->instruction.sarrbuild.nb_tab;i++)
								{
									int index_src;
									char prefixe_src[MAX_IDENT];

									index_src=recherche_variable(inst->instruction.sarrbuild.label[i],inst->bloc);

									if(strcmp(program.vg[index_src].bloc,"0")==0)
										strcpy(prefixe_src,"globale");
									else
										strcpy(prefixe_src,program.vg[index_src].bloc);

									if(i>0) fprintf(file_code,",");

									fprintf(file_code,"%s_%s ",prefixe_src,inst->instruction.sarrbuild.label[i]);
								}

					}break;




				case INST_RETURN :
					{
							SEXPRESSION *exp;
							int type;
							int j,k,l;
							char *rtype,*type_ret,*typer;

	 						exp=inst->instruction.sreturn.expression_ptr;
							type=inst->instruction.sreturn.exp;

	 						if(etat_trace2==1) fprintf(file_code,"\n//%s__________________________________________________________________________________",affiche);
							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION RETURN ",affiche);
							if(type==1)
	 							{
									rtype=genere_recursif(exp,0,bloc,NULL);

									for(j=0;j<nb_fonction;j++)
										if(strcmp(bloc,tab_fonction[j].ident_fonction)==0) break;

									if(j==nb_fonction)
									 {
										char libelle[200];

										sprintf(libelle,GC0450,bloc);
									 	message_erreur(libelle);
									 }

									type_ret=convertit_type_gen(tab_fonction[j].type_variable_retournee_ptr->type,0);

									typer=calcul_type_resultant(type_ret,rtype);

									k=recherche_atome(typer);
									l=recherche_atome(type_ret);

									if(recherche_atome(type_ret)==-1)
										{
											if(strcmp(rtype,type_ret)!=0)
									 			{
													char libelle[200];

													sprintf(libelle,GC0460,
														bloc,rtype,type_ret);
									 				message_erreur(libelle);
									 			}
										}
									else
										if(k!=l)
											{
													char libelle[200];

													sprintf(libelle,GC0470,
														bloc,rtype,type_ret);
									 				message_erreur(libelle);
											}

									if(strcmp(type_ret,rtype)!=0) /* on ne genere ce code que si les types sont différents */
										fprintf(file_code,"\n\tmov expr_%s_%s, expr_%s_%s",type_ret,bloc,rtype,bloc);
								}
							else {if(etat_trace2==1) fprintf(file_code,"\n//%s  RETURN VIDE ",affiche);}

						    fprintf(file_code,"\n\tjmp return_%s",bloc);

							if(etat_trace2==1) fprintf(file_code,"\n//%s__________________________________________________________________________________",affiche);
					}break;
				case INST_EXIT:
				    {
						monte();

						if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION EXIT()", affiche);

						fprintf(file_code,"\n\tstop 1");

						descend();
					}break;
				case INST_PRECEDES:
					{
					  int i;
					  int index;

					  if(inst->instruction.sprecedes.nb_label>0)
					   {

						    monte();
	 						if(etat_trace2==1) fprintf(file_code,"\n//%s__________________________________________________________________________________",affiche);
							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION PRECEDES ",affiche);
							for(i=0;i<inst->instruction.sprecedes.nb_label;i++)
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s tache = '%s' ",affiche,&inst->instruction.sprecedes.label[i][0]);
								}

							fprintf(file_code,"\n\tprecedes ");

							for(i=0;i<inst->instruction.sprecedes.nb_label;i++)
								{
									rechercher_tache(&inst->instruction.sprecedes.label[i][0],inst->bloc);
									fprintf(file_code,"%s ",&inst->instruction.sprecedes.label[i][0]);
								}

	 						if(etat_trace2==1) fprintf(file_code,"\n//%s__________________________________________________________________________________",affiche);
						    descend();
					   }

					}break;
				case INST_BREAK	:
					{
						INSTRUCTION *inst_boucle;

						monte();
							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION BREAK => SAUT SORTIE DE BOUCLE ", affiche);

						inst_boucle=consulte_boucle();

						if(inst_boucle->type_instruction==INST_FOR)
								 fprintf(file_code,"\n\tjmp break_%s_for_%d",inst_boucle->bloc,inst_boucle->index);
						else if(inst_boucle->type_instruction==INST_DO_REPEAT)
								 fprintf(file_code,"\n\tjmp break_%s_do_while_%d",inst_boucle->bloc,inst_boucle->index);

						descend();
					}break;
				case INST_CASE :
					{
							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION CASE ", affiche);
					}break;
				case INST_CONTINUE :
					{
						INSTRUCTION *inst_boucle;

						monte();
							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION CONTINUE => SAUT DEBUT DE BOUCLE ", affiche);

						inst_boucle=consulte_boucle();

						if(inst_boucle->type_instruction==INST_FOR)
								 fprintf(file_code,"\n\tjmp continue_%s_for_%d",inst_boucle->bloc,inst_boucle->index);
						else if(inst_boucle->type_instruction==INST_DO_REPEAT)
								 fprintf(file_code,"\n\tjmp %s_do_while_%d",inst_boucle->bloc,inst_boucle->index);
						descend();
					}break;
				case INST_AFFECTATION :
					{
						char 		*rtype1,*rtype2,*rtype;
						SEXPRESSION *exp1;
						SVARIABLE 	*suivant;
						int 		dim,type;

						monte();

/*				printf("\naff %lx",inst->instruction.saffectation);*/
							if(inst->instruction.saffectation->type_affectation==AFF_PTR)
								{
				/*printf("\n A");*/
									if(etat_trace2==1) fprintf(file_code,"\n//%s = AFF POINTEUR ",affiche);
				/*printf("\n B");*/
									rtype1=genere_recursif(inst->instruction.saffectation->valeur_affectee,0,bloc,NULL);
				/*printf("\n C");*/
									if(strcmp(rtype1,"void")==0)
										{
											char libelle[200];

											sprintf(libelle,GC0480,
														inst->instruction.saffectation->variable->feuille.svariable.ident_variable);
									 		message_erreur(libelle);
									 	}
				/*printf("\n D");*/
									exp1=inst->instruction.saffectation->valeur_affectee;
				/*printf("\n E");*/
									type=exp1->type;
				/*printf("\n F");*/
									fprintf(file_code,"\n\tmov expr_aff_%s_%s, expr_%s_%s // affectation 0",rtype1,bloc,rtype1,bloc);
				/*printf("\n G");*/
									rtype2=genere_recursif(inst->instruction.saffectation->variable,1,bloc,rtype1);
				/*printf("\n H");*/
									rtype=calcul_type_resultant(rtype1,rtype2);
				/*printf("\n I");*/
								}
							else if(inst->instruction.saffectation->type_affectation==AFF_EXP)
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s = AFF VARIABLE SIMPLE ",affiche);
									rtype1=genere_recursif(inst->instruction.saffectation->valeur_affectee,0,bloc,NULL);

									if(strcmp(rtype1,"void")==0)
										{
											char libelle[200];

											sprintf(libelle,GC0490,
														inst->instruction.saffectation->variable->feuille.svariable.ident_variable);
									 		message_erreur(libelle);
									 	}

									exp1=inst->instruction.saffectation->valeur_affectee;
									type=exp1->type;

									if(type==EXP_VARIABLE) /* c'est une variable */
										{
											suivant=exp1->feuille.svariable.suivant;
											dim=exp1->feuille.svariable.variable_ptr->type_variable_ptr->nb_dimension;
											/*printf("\n suivant=%lx d=%d",suivant,dim);*/

											if((suivant==NULL)&&(dim>0)) /* affectation d'un tableau */
												{
				/* à corriger si tableau d'atome, tab en trop */
													int ind_tab;

													ind_tab=recherche_tab_atome(rtype1);

													if(ind_tab==-1)
														fprintf(file_code,"\n\tmov expr_aff_%s_tab_%s, expr_%s_tab_%s // affectation 1",rtype1,bloc,rtype1,bloc);
													else
														fprintf(file_code,"\n\tmov expr_aff_%s_%s, expr_%s_%s // affectation 1 tab d'atome",rtype1,bloc,rtype1,bloc);
												}
											else /* ce n'est pas un tableau */
												fprintf(file_code,"\n\tmov expr_aff_%s_%s, expr_%s_%s // affectation 2",rtype1,bloc,rtype1,bloc);
										}
									else /* c'est une expression */
										fprintf(file_code,"\n\tmov expr_aff_%s_%s, expr_%s_%s // affectation 3 ",rtype1,bloc,rtype1,bloc);

									rtype2=genere_recursif(inst->instruction.saffectation->variable,1,bloc,rtype1);
									rtype=calcul_type_resultant(rtype1,rtype2);
								}
							else if(inst->instruction.saffectation->type_affectation==AFF_INC)
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s ++ INCREMENTATION ",affiche);
									genere_recursif(inst->instruction.saffectation->variable,2,bloc,NULL);
								}
							else if(inst->instruction.saffectation->type_affectation==AFF_DEC)
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s -- DECREMENTATION ",affiche);
									genere_recursif(inst->instruction.saffectation->variable,3,bloc,NULL);
								}

							/*fprintf(file_code,"\n\tmov expr_d_word, expr_word");*/

							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION AFFECTATION %lx %lx",
								affiche,
								inst->instruction.saffectation->variable,
								inst->instruction.saffectation->valeur_affectee);



							/*fprintf(file_code,"\n\tmov expr_word,expr_d_word");*/

						descend();
					}break;
				case INST_FONCTION :
					{
						monte();

						if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION FONCTION ", affiche);

						genere_recursif(inst->instruction.sfonction,0,bloc,NULL);

						descend();

					}break;
				case INST_BLOC :
					{
							int i;

							if(etat_trace2==1) fprintf(file_code,"\n//%s INSTRUCTION BLOC ", affiche);

							monte();

							if(inst->instruction.sbloc.nb_instruction==0)
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s BLOC VIDE ", affiche);
							    }
							else
								{
									if(etat_trace2==1) fprintf(file_code,"\n//%s LISTE INSTRUCTION BLOC nb_inst %d", affiche,inst->instruction.sbloc.nb_instruction);

									for(i=0;i< inst->instruction.sbloc.nb_instruction;i++)
									{
										if(etat_trace2==1) fprintf(file_code,"\n//%s SOUS INSTRUCTION BLOC %d", affiche,i);
										genere_instruction(inst->instruction.sbloc.liste_instruction[i],bloc);
									}
								}

							descend();
					}break;
		     }
	   }

	  descend();
  }


int recherche_appel_de_fonction(char *nom_fonction)
 {
	int i;

	for(i=0;i<nb_fonctions_appelees;i++)
		 if(strcmp((char *)&tab_fonctions_appelees[i][0],nom_fonction)==0)
			 	break;

	if(i==nb_fonctions_appelees)
			return(-1); /* fonction jamais appellee */
	else    return(1);	/* fonction appelee */
 }

/* fonction de generation de fonctions */

void genere_fonctions(void)
 {
	 int i;

	 for(i=0;i<nb_fonction;i++)
		 {
			 if(recherche_appel_de_fonction(tab_fonction[i].ident_fonction)==1)
				 {

			  		fprintf(file_code,"\n\n//_________________________________________________\n// %s()\n// {",tab_fonction[i].ident_fonction);
			  		fprintf(file_code,"\nsubroutine %s",tab_fonction[i].ident_fonction);

			  		/*genere_variables(tab_fonction[i].ident_fonction);*/

			  		if(etat_trace2==1) fprintf(file_code,"\n//%s ALLOCATION DU TABLEAU D'INDEX ", affiche);

			  		fprintf(file_code,"\n\tarrinit index_tab_%s, 0, 100",tab_fonction[i].ident_fonction);

			  		fprintf(file_code,"\n// BODY");

			  		genere_instruction(tab_fonction[i].liste_instruction,tab_fonction[i].ident_fonction);

			  		fprintf(file_code,"\n\treturn_%s:",tab_fonction[i].ident_fonction);
			  		fprintf(file_code,"\n\treturn");

			  		fprintf(file_code,"\nends");
			  		fprintf(file_code,"\n // }\n// End of subroutine %s()",tab_fonction[i].ident_fonction);
				}
			 /*else
			 	printf("\n\t Function '%s' not called, therefore not generated",tab_fonction[i].ident_fonction);*/
		 }

 }

/* fonctions de generation de taches */

void genere_taches(void)
 {
	 int i;

	 for(i=0;i<nb_tache;i++)
		 {
			  fprintf(file_code,"\n\n//_________________________________________________\n// task %s()\n// {",tab_tache[i].ident_tache);
			  fprintf(file_code,"\nthread %s",tab_tache[i].ident_tache);

			  /*genere_variables(tab_tache[i].ident_tache);*/

			  if(etat_trace2==1) fprintf(file_code,"\n//%s ALLOCATION DU TABLEAU D'INDEX ", affiche);
			  fprintf(file_code,"\n\tarrinit index_tab_%s, 0, 100",tab_tache[i].ident_tache);


			  fprintf(file_code,"\n// BODY");


			  if(strcmp(tab_tache[i].ident_tache,"main")==0)
				  {
					  int j;

					  for(j=0;j<nb_tache;j++)
						  {
								fprintf(file_code,"\n\tarrinit expr_pile_byte_%s,   0, 100",tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tarrinit expr_pile_sbyte_%s,  0, 100",tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tarrinit expr_pile_word_%s,   0, 100",tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tarrinit expr_pile_sword_%s,  0, 100",tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tarrinit expr_pile_dword_%s,  0, 100",tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tarrinit expr_pile_sdword_%s, 0, 100",tab_tache[j].ident_tache);

								fprintf(file_code,"\n\tset expr_ptr_pile_byte_%s, 0",		tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tset expr_ptr_pile_sbyte_%s, 0",		tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tset expr_ptr_pile_word_%s, 0",		tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tset expr_ptr_pile_sword_%s, 0",		tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tset expr_ptr_pile_dword_%s, 0",		tab_tache[j].ident_tache);
			  					fprintf(file_code,"\n\tset expr_ptr_pile_sdword_%s, 0",		tab_tache[j].ident_tache);
				  		  }

					  for(j=0;j<nb_fonction;j++)
		 				  {
							  if(recherche_appel_de_fonction(tab_fonction[j].ident_fonction)==1)
							   {
							  	 if(tab_fonction[j].librairie==0)
								  {
							    		fprintf(file_code,"\n\tarrinit expr_pile_byte_%s,   0, 100",tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tarrinit expr_pile_sbyte_%s,  0, 100",tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tarrinit expr_pile_word_%s,   0, 100",tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tarrinit expr_pile_sword_%s,  0, 100",tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tarrinit expr_pile_dword_%s,  0, 100",tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tarrinit expr_pile_sdword_%s, 0, 100",tab_fonction[j].ident_fonction);

										fprintf(file_code,"\n\tset expr_ptr_pile_byte_%s, 0",		tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tset expr_ptr_pile_sbyte_%s, 0",		tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tset expr_ptr_pile_word_%s, 0",		tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tset expr_ptr_pile_sword_%s, 0",		tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tset expr_ptr_pile_dword_%s, 0",		tab_fonction[j].ident_fonction);
			  							fprintf(file_code,"\n\tset expr_ptr_pile_sdword_%s, 0",		tab_fonction[j].ident_fonction);
								  }
							   }
						  }

				  }

			  genere_instruction(tab_tache[i].liste_instruction,tab_tache[i].ident_tache);

			  fprintf(file_code,"\nendt");
			  fprintf(file_code,"\n // }\n// End of task %s()",tab_tache[i].ident_tache);
		 }
 }

void genere_mutex(void)
 {
	 int i;
	 char ident[MAX_IDENT];

	 if(etat_trace2==1) fprintf(file_code,"\n//DECLARATION DES MUTEX ");


	 for(i=0;i<nb_fonction;i++)
		 {
			  if(recherche_appel_de_fonction(tab_fonction[i].ident_fonction)==1)
				  {
			  		sprintf(ident,"mutex_%s",tab_fonction[i].ident_fonction);
			  		strcpy(tab_mutex[nb_mutex].ident,ident);
			  		strcpy(tab_mutex[nb_mutex].module,"automatic");
			  		tab_mutex[nb_mutex].ligne=0;
			  		nb_mutex++;
				  }
		 }


	 for(i=0;i<nb_mutex;i++)
		 {
			 /* sprintf(ident,"%s_%d",ident,i);*/
			  fprintf(file_code,"\n\t%s mutex // module=%s ligne =%d ident=%s",
			  			tab_mutex[i].ident,
						tab_mutex[i].module,
						tab_mutex[i].ligne,
						tab_mutex[i].ident);

		 }

	 if(etat_trace2==1) fprintf(file_code,"\n//FIN DE DECLARATION DES MUTEX ");
 }

/* fonction de generation de code */
void genere_code(void)
 {
	int i;

	fprintf(file_code,"#include \"NXTDefs.h\"");

    fprintf(file_code,"\ndseg segment");

	genere_types();

	genere_variables("0",0,0);

	genere_mutex();

	for(i=0;i<nb_tache;i++)
		 {
			  genere_variables(tab_tache[i].ident_tache,0,0);
		 }

	for(i=0;i<nb_fonction;i++)
		 {
			 if(recherche_appel_de_fonction(tab_fonction[i].ident_fonction)==1)
				 {
			 		 genere_variables(tab_fonction[i].ident_fonction,tab_fonction[i].librairie,i);
				 }
		 }

	fprintf(file_code,"\ndseg ends");

	genere_taches();
	genere_fonctions();

	fprintf(file_code,"\n// End of program");

 }


/* fonction de generation de codes */
extern void generation_de_code(char *nom)
 {
	char tampon[1000];

	strcpy(tampon,nom);

	strcpy(&tampon[strlen(nom)-3],"nbc");

	file_code=fopen(tampon,"w");

    if(file_code==(FILE *)NULL)
     {
		message_erreur(GC0500);
     }

	init_tab_atome();

	genere_code();

	fclose(file_code);
 }



