diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/assembler.c | 234 | ||||
| -rw-r--r-- | lib/hash.c | 8 | ||||
| -rw-r--r-- | lib/linker.c | 26 | ||||
| -rw-r--r-- | lib/meta.c | 63 | ||||
| -rw-r--r-- | lib/parser.c | 9 | ||||
| -rw-r--r-- | lib/simulator.c | 54 | 
6 files changed, 118 insertions, 276 deletions
| diff --git a/lib/assembler.c b/lib/assembler.c index 0beb2df..0acf738 100644 --- a/lib/assembler.c +++ b/lib/assembler.c @@ -176,9 +176,7 @@ static bytestream_t *pushdword(unsigned long int d, expression_t * e)      bytestream_t *s;      if ((segment < 0) || (segment > 1)) { -	exception(1, -		  _ -		  ("You have to be into the .text or the .data segment to define a value.")); +	exception(1, _("You have to be into the .text or the .data segment to define a value."));      }      s = pushuninit(1); @@ -267,9 +265,7 @@ static void pushstring(char *s)  static void pushstart(void)  {      if (segment != SEG_TEXT) { -	exception(1, -		  _ -		  ("You can't have the startpoint elsewhere than the .text segment")); +	exception(1, _("You can't have the startpoint elsewhere than the .text segment"));      }      pushlabel("__start__");  } @@ -282,9 +278,7 @@ static void look4pattern(pattern_t * patterns, expression_t * expression)      for (patterns = patterns->next; patterns; patterns = patterns->next) {  	for (i = 0; i < patterns->nbr; i++) { -	    if (! -		(patterns->expr[i]->type -		 || patterns->expr[i]->string || !patterns->expr[i]->name)) { +	    if (!(patterns->expr[i]->type || patterns->expr[i]->string || !patterns->expr[i]->name)) {  		if (!strcasecmp(patterns->expr[i]->name, expression->symbol)) {  		    expression->e_subtype = E_PATTERN;  		    expression->pattern = patterns; @@ -661,8 +655,7 @@ static void evaluate(expression_t * e)  	if (!e->child->e_subtype == E_VALUE) {  	    exception(1, _("Error: unable to compute the immediate value"));  	} -	e->avalue = -	    (e->op == OP_MOINS_UNARY) ? -e->child->avalue : e->child->avalue; +	e->avalue = (e->op == OP_MOINS_UNARY) ? -e->child->avalue : e->child->avalue;  	free(e->child);  	e->child = NULL;  	e->e_type = e->e_subtype = E_VALUE; @@ -696,8 +689,7 @@ static void evaluate(expression_t * e)  	    if (e->child->next->child->e_subtype == E_LABEL) {  		exception(1, _("Addresses operations not allowed"));  	    } -	    if (e->child->next->child->e_subtype == -		e->child->next->child->next->e_subtype) { +	    if (e->child->next->child->e_subtype == e->child->next->child->next->e_subtype) {  		exception(1, _("Expression too complex or invalid"));  	    }  	    /* On veut obtenir quelque chose sous la forme LABEL[VALUE + PATTERN] */ @@ -808,9 +800,7 @@ static void evaluate(expression_t * e)  			   et si c'est le cas, il ne faut pas que ce soit - C. Sinon nous ne devons  			   pas avoir de labels pour B ou C */ -			if ( -			    (e->child->child->next->child->next->e_subtype == -			     E_PATTERN) +			if ((e->child->child->next->child->next->e_subtype == E_PATTERN)  			    && (e->child->child->next->op == OP_MOINS)) {  			    exception(1, _("Address type not supported"));  			} @@ -823,18 +813,14 @@ static void evaluate(expression_t * e)  			if (e->child->child->next->child->e_subtype ==  			    e->child->child->next->child->next->e_subtype) { -			    exception(1, -				      _("Expression too complex or invalid")); +			    exception(1, _("Expression too complex or invalid"));  			}  			/* Ok, si notre expression a réussi à franchir toutes ses étapes, c'est qu'elle  			   est correcte.... Enfin j'espère :) Je vais modifier l'expression de sorte a ce  			   qu'elle ait la forme [LABEL + (VALEUR +- PATTERN)] */ -			if ( -			    (t = -			     e->child->child->next->child)->e_subtype == -			    E_PATTERN) { +			if ((t = e->child->child->next->child)->e_subtype == E_PATTERN) {  			    t->prev = t->next;  			    t->next = NULL;  			    t->prev->next = t; @@ -851,15 +837,12 @@ static void evaluate(expression_t * e)  			   et si c'est le cas, il ne faut pas que ce soit - C. Sinon nous ne devons  			   pas avoir de patterns pour B ou C. */ -			if ( -			    (e->child->child->next->child->next->e_subtype == -			     E_LABEL) +			if ((e->child->child->next->child->next->e_subtype == E_LABEL)  			    && (e->child->child->next->op == OP_MOINS)) {  			    exception(1, _("Address type not supported"));  			} -			if (e->child->child->next->child->e_subtype == -			    E_PATTERN) { +			if (e->child->child->next->child->e_subtype == E_PATTERN) {  			    exception(1, _("Expression invalid"));  			} @@ -867,8 +850,7 @@ static void evaluate(expression_t * e)  			if (e->child->child->next->child->e_subtype ==  			    e->child->child->next->child->next->e_subtype) { -			    exception(1, -				      _("Expression too complex or invalid")); +			    exception(1, _("Expression too complex or invalid"));  			}  			/* Ok, si notre expression a réussi à franchir toutes ses étapes, c'est qu'elle @@ -876,10 +858,7 @@ static void evaluate(expression_t * e)  			   qu'elle ait la forme [LABEL + (VALEUR +- PATTERN)] */  			/* Pas mal de boulot ici... */ -			if ( -			    (t = -			     e->child->child->next->child)->e_subtype == -			    E_LABEL) { +			if ((t = e->child->child->next->child)->e_subtype == E_LABEL) {  			    /* Nous avons [PATTERN + (LABEL +- VALEUR)], on inverse LABEL et VALEUR */  			    t->prev = t->next;  			    t->next = NULL; @@ -918,8 +897,7 @@ static void evaluate(expression_t * e)  			    if (e->child->child->next->op == OP_MOINS) {  				exception(1, _("Expression invalid"));  			    } -			    e->child->child->avalue += -				e->child->child->next->child->avalue; +			    e->child->child->avalue += e->child->child->next->child->avalue;  			    t = e->child->child->next;  			    e->child->child->next = t->child->next;  			    free_expr(t); @@ -927,15 +905,12 @@ static void evaluate(expression_t * e)  			       On va pas s'embeter, on va réévaluer la chose :) */  			    evaluate(e);  			    return; -			} else if (e->child->child->next->child-> -				   next->e_subtype == E_VALUE) { +			} else if (e->child->child->next->child->next->e_subtype == E_VALUE) {  			    /* Quasiment la même chose qu'au dessus... */  			    if (e->child->child->next->op == OP_MOINS) { -				e->child->child->avalue -				    -= e->child->child->next->child->avalue; +				e->child->child->avalue -= e->child->child->next->child->avalue;  			    } else { -				e->child->child->avalue -				    += e->child->child->next->child->avalue; +				e->child->child->avalue += e->child->child->next->child->avalue;  			    }  			    t = e->child->child->next;  			    e->child->child->next = t->child; @@ -947,9 +922,7 @@ static void evaluate(expression_t * e)  			    if (e->child->child->next->child->e_subtype ==  				e->child->child->next->child->next->e_subtype) { -				exception(1, -					  _ -					  ("Expression too complex or invalid")); +				exception(1, _("Expression too complex or invalid"));  			    }  			    /* Ok, si notre expression a réussi à franchir toutes ses étapes, c'est qu'elle @@ -957,10 +930,7 @@ static void evaluate(expression_t * e)  			       qu'elle ait la forme [LABEL + (VALEUR +- PATTERN)] */  			    /* Pas mal de boulot ici... */ -			    if ( -				(t = -				 e->child->child->next->child)->e_subtype == -				E_PATTERN) { +			    if ((t = e->child->child->next->child)->e_subtype == E_PATTERN) {  				/* Nous avons [VALEUR + (PATTERN + LABEL)], on inverse LABEL et PATTERN */  				t->prev = t->next;  				t->next = NULL; @@ -1254,8 +1224,7 @@ static int islabel(expression_t * e)  /* Cette fonction cherche une instruction pouvant correspondre à l'expression. */ -static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, -			     expression_t * e) +static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_t * e)  {      char *stringtolook = e->symbol;      expression_t *t; @@ -1281,8 +1250,7 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs,  	go_out = 0;  	for (i = 0; (!go_out) && (i < instructs->nbexplicit); i++) {  	    if (!instructs->strings[i]) { -		if (strcasecmp -		    (instructs->names[i], i ? t->symbol : stringtolook)) { +		if (strcasecmp(instructs->names[i], i ? t->symbol : stringtolook)) {  		    go_out = 1;  		}  	    } else { @@ -1291,9 +1259,8 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs,  		    if (!t->pattern) {  			go_out = 1;  		    } else { -			if (strcasecmp -			    (instructs->strings[i] + 1, -			     t->pattern->name)) go_out = 1; +			if (strcasecmp(instructs->strings[i] + 1, t->pattern->name)) +			    go_out = 1;  		    }  		    break;  		case 'C': @@ -1323,9 +1290,7 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs,  		    /* C'est le cas le plus simple ou presque, il suffit de tout prendre */  		    break;  		default: -		    exception(1, -			      _ -			      ("Unknow predefined string into the meta language")); +		    exception(1, _("Unknow predefined string into the meta language"));  		}  	    } @@ -1347,10 +1312,8 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs,  	for (i = 0; i < instructs->nbexplicit; i++) {  	    fprintf(stderr, "    + %s <= %s (type %s)\n",  		    instructs->names[i], -		    instructs-> -		    strings[i] ? instructs->strings[i] : -		    "Pas de chaîne associée", -		    instructs->etypes[i] ? "prédéfinit" : "direct"); +		    instructs->strings[i] ? instructs->strings[i] : +		    "Pas de chaîne associée", instructs->etypes[i] ? "prédéfinit" : "direct");  	}  	fprintf(stderr, "  => Champs implicites.\n");  	for (i = 0; i < instructs->nbimplicit; i++) { @@ -1394,8 +1357,7 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)  	if (m->string) {  	    if (m->type) {  		if (strcmp(m->name, "I")) { -		    exception(1, -			      _("Unknow constant type in the meta language")); +		    exception(1, _("Unknow constant type in the meta language"));  		}  		if (e->e_subtype == E_VALUE) {  		    pushdword(e->avalue, NULL); @@ -1428,9 +1390,7 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)  		if (m->type) {  		    if (strcmp(m->name, "I")  			|| strcmp(m->string, "O")) { -			exception(1, -				  _ -				  ("Unknow constant type in the meta language")); +			exception(1, _("Unknow constant type in the meta language"));  		    }  		    tv = 0;  		    if (e->child->next->e_subtype == E_VALUE) { @@ -1660,9 +1620,7 @@ void asm_eol(void)  	    if (!e_current)  		break;  	    if (segment != SEG_TEXT) { -		exception(1, -			  _ -			  ("You can only have an instruction into a .text segment")); +		exception(1, _("You can only have an instruction into a .text segment"));  	    }  	    if (!(instr = e_match_i(phons, instructs, e_current))) {  		exception(1, _("Unmatched instruction")); @@ -1686,14 +1644,10 @@ void asm_eol(void)  				    pushdword(0, e_current);  				}  			    } else { -				exception(1, -					  _ -					  ("Unknow constant type in the meta language")); +				exception(1, _("Unknow constant type in the meta language"));  			    }  			} else { -			    InsererVarDansTab(&it, -					      CreerElement -					      (instr->names[i], e_current)); +			    InsererVarDansTab(&it, CreerElement(instr->names[i], e_current));  			}  			break;  		    case 'O': @@ -1705,9 +1659,7 @@ void asm_eol(void)  				    pushdword(0, e_current);  				}  			    } else { -				exception(1, -					  _ -					  ("Unknow constant type in the meta language")); +				exception(1, _("Unknow constant type in the meta language"));  			    }  			}  			break; @@ -1719,19 +1671,14 @@ void asm_eol(void)  			t->child = t->next = NULL;  			t->pattern = NULL;  			t->symbol = NULL; -			InsererVarDansTab(&it, -					  CreerElement(instr->names[i], t)); +			InsererVarDansTab(&it, CreerElement(instr->names[i], t));  #ifdef DEBUG -			fprintf(stderr, -				"On a %s qui vaut %i\n", -				instr->names[i], e_current->index); +			fprintf(stderr, "On a %s qui vaut %i\n", instr->names[i], e_current->index);  #endif  			evaluate_pattern(&it, e_current);  			break;  		    default: -			exception(1, -				  _ -				  ("Unknow constant type in the meta language")); +			exception(1, _("Unknow constant type in the meta language"));  		    }  		} @@ -1756,11 +1703,9 @@ void asm_eol(void)  			t->symbol = NULL;  		    }  #ifdef DEBUG -		    fprintf(stderr, "On a %s qui vaut %i\n", -			    instr->implicits[i], t->avalue); +		    fprintf(stderr, "On a %s qui vaut %i\n", instr->implicits[i], t->avalue);  #endif -		    InsererVarDansTab(&it, -				      CreerElement(instr->implicits[i], t)); +		    InsererVarDansTab(&it, CreerElement(instr->implicits[i], t));  		    break;  		case 1:	/* type prédéfinit */  		    t = (expression_t *) @@ -1774,11 +1719,9 @@ void asm_eol(void)  		    t->pattern = NULL;  		    t->symbol = NULL;  #ifdef DEBUG -		    fprintf(stderr, "On a %s qui vaut %i\n", -			    instr->implicits[i], t->avalue); +		    fprintf(stderr, "On a %s qui vaut %i\n", instr->implicits[i], t->avalue);  #endif -		    InsererVarDansTab(&it, -				      CreerElement(instr->implicits[i], t)); +		    InsererVarDansTab(&it, CreerElement(instr->implicits[i], t));  		    break;  		case 2:	/* type valeur */  		    t = (expression_t *) @@ -1789,11 +1732,9 @@ void asm_eol(void)  		    t->pattern = NULL;  		    t->symbol = NULL;  #ifdef DEBUG -		    fprintf(stderr, "On a %s qui vaut %i\n", -			    instr->implicits[i], t->avalue); +		    fprintf(stderr, "On a %s qui vaut %i\n", instr->implicits[i], t->avalue);  #endif -		    InsererVarDansTab(&it, -				      CreerElement(instr->implicits[i], t)); +		    InsererVarDansTab(&it, CreerElement(instr->implicits[i], t));  		    break;  		}  	    } @@ -1952,9 +1893,7 @@ void asm_eof(FILE * f)  		    if ((ttext->Expr->child->e_subtype == E_LABEL)  			&& (ttext->Expr->child->next->e_subtype == E_VALUE)) {  #ifdef DEBUG -			fprintf(stderr, -				"Symbole externe %s\n", -				ttext->Expr->child->symbol); +			fprintf(stderr, "Symbole externe %s\n", ttext->Expr->child->symbol);  #endif  			a = ttext->Expr->child->next->avalue;  			nbsymbols++; @@ -1970,35 +1909,28 @@ void asm_eof(FILE * f)  		    if (((ttext->Expr->child->e_subtype == E_LABEL)  			 && (ttext->Expr->child->next->e_subtype == E_VALUE))  			|| ((ttext->Expr->child->e_subtype == E_VALUE) -			    && (ttext->Expr->child->next->e_subtype == -				E_LABEL))) { +			    && (ttext->Expr->child->next->e_subtype == E_LABEL))) {  			if (ttext->Expr->child->e_subtype == E_LABEL) {  #ifdef DEBUG -			    fprintf(stderr, -				    "Symbole externe %s\n", -				    ttext->Expr->child->symbol); +			    fprintf(stderr, "Symbole externe %s\n", ttext->Expr->child->symbol);  #endif  			    a = ttext->Expr->child->next->avalue;  			    nbsymbols++;  			    writeword(1, f2, 1);  			    writeword(ttext->offset, f2, 1); -			    writeword(strlen -				      (ttext->Expr->child->symbol), f2, 1); +			    writeword(strlen(ttext->Expr->child->symbol), f2, 1);  			    writestring(ttext->Expr->child->symbol, f2);  			    nbe++;  			} else {  #ifdef DEBUG  			    fprintf(stderr, -				    "Symbole externe %s\n", -				    ttext->Expr->child->next->symbol); +				    "Symbole externe %s\n", ttext->Expr->child->next->symbol);  #endif  			    a = ttext->Expr->child->avalue;  			    nbsymbols++;  			    writeword(1, f2, 1);  			    writeword(ttext->offset, f2, 1); -			    writeword(strlen -				      (ttext->Expr->child->next->symbol), f2, -				      1); +			    writeword(strlen(ttext->Expr->child->next->symbol), f2, 1);  			    writestring(ttext->Expr->child->next->symbol, f2);  			    nbe++;  			} @@ -2006,42 +1938,28 @@ void asm_eof(FILE * f)  		    }  		}  		if (ttext->Expr->op != OP_FUNC_CALL) { -		    exception(1, -			      _ -			      ("Can't evaluate expression for a direct value")); +		    exception(1, _("Can't evaluate expression for a direct value"));  		}  		if (strcmp(ttext->Expr->symbol, "diff")) { -		    exception(1, -			      _ -			      ("Can't evaluate expression for a direct value")); +		    exception(1, _("Can't evaluate expression for a direct value"));  		}  		if ((ttext->Expr->child->e_subtype != E_LABEL)  		    || (ttext->Expr->child->next->e_subtype != E_LABEL)) { -		    exception(1, -			      _ -			      ("Can only use the diff() function onto labels")); +		    exception(1, _("Can only use the diff() function onto labels"));  		} -		t = -		    (bytestream_t *) NomVarToVar(ttext->Expr->child->symbol, -						 labels, &trouve); +		t = (bytestream_t *) NomVarToVar(ttext->Expr->child->symbol, labels, &trouve);  		if (!trouve) { -		    exception(1, -			      _("Can only evaluate a diff on local symbols")); +		    exception(1, _("Can only evaluate a diff on local symbols"));  		} -		u = -		    (bytestream_t *) -		    NomVarToVar(ttext->Expr->child->next->symbol, labels, -				&trouve); +		u = (bytestream_t *) +		    NomVarToVar(ttext->Expr->child->next->symbol, labels, &trouve);  		if (!trouve) { -		    exception(1, -			      _("Can only evaluate a diff on local symbols")); +		    exception(1, _("Can only evaluate a diff on local symbols"));  		}  		if (t->segment != u->segment) { -		    exception(1, -			      _ -			      ("Can only evaluate a diff on symbols from the same segment")); +		    exception(1, _("Can only evaluate a diff on symbols from the same segment"));  		}  		a = t->offset - u->offset; @@ -2099,8 +2017,7 @@ void asm_eof(FILE * f)  	    case E_LABEL:  		a = tdata->Expr->avalue;  #ifdef DEBUG -		fprintf(stderr, "Symbole externe %s\n", -			tdata->Expr->child->symbol); +		fprintf(stderr, "Symbole externe %s\n", tdata->Expr->child->symbol);  #endif  		nbsymbols++;  		writeword(3, f2, 1); @@ -2111,42 +2028,28 @@ void asm_eof(FILE * f)  		break;  	    case E_OPERATION:  		if (tdata->Expr->op != OP_FUNC_CALL) { -		    exception(1, -			      _ -			      ("Can't evaluate expression for a direct value")); +		    exception(1, _("Can't evaluate expression for a direct value"));  		}  		if (strcmp(tdata->Expr->symbol, "diff")) { -		    exception(1, -			      _ -			      ("Can't evaluate expression for a direct value")); +		    exception(1, _("Can't evaluate expression for a direct value"));  		}  		if ((tdata->Expr->child->e_subtype != E_LABEL)  		    || (tdata->Expr->child->next->e_subtype != E_LABEL)) { -		    exception(1, -			      _ -			      ("Can only use the diff() function onto labels")); +		    exception(1, _("Can only use the diff() function onto labels"));  		} -		t = -		    (bytestream_t *) NomVarToVar(tdata->Expr->child->symbol, -						 labels, &trouve); +		t = (bytestream_t *) NomVarToVar(tdata->Expr->child->symbol, labels, &trouve);  		if (!trouve) { -		    exception(1, -			      _("Can only evaluate a diff on local symbols")); +		    exception(1, _("Can only evaluate a diff on local symbols"));  		} -		u = -		    (bytestream_t *) -		    NomVarToVar(tdata->Expr->child->next->symbol, labels, -				&trouve); +		u = (bytestream_t *) +		    NomVarToVar(tdata->Expr->child->next->symbol, labels, &trouve);  		if (!trouve) { -		    exception(1, -			      _("Can only evaluate a diff on local symbols")); +		    exception(1, _("Can only evaluate a diff on local symbols"));  		}  		if (t->segment != u->segment) { -		    exception(1, -			      _ -			      ("Can only evaluate a diff on symbols from the same segment")); +		    exception(1, _("Can only evaluate a diff on symbols from the same segment"));  		}  		a = t->offset - u->offset; @@ -2209,7 +2112,7 @@ void asm_eof(FILE * f)      popcontext();      writeword(0x4f424e4e, f, 1); -    writeword(ftell(f2) + s_data + s_text + 7, f, 1); +    writeword((ftell(f2) >> 2)+ s_data + s_text + 7, f, 1);      t = (bytestream_t *) NomVarToVar("__start__", labels, &trouve);      if (trouve) {  	writeword(t->offset, f, 1); @@ -2220,7 +2123,7 @@ void asm_eof(FILE * f)      writeword(s_text, f, 1);      writeword(s_data, f, 1);      writeword(s_bss, f, 1); -    writeword(ftell(f2) + 1, f, 1); +    writeword((ftell(f2) >> 2) + 1, f, 1);      fclose(f2);      writeword(nbsymbols, f, 1); @@ -2256,8 +2159,7 @@ void assembler_flush(void)      delete_bytestream(data);      delete_bytestream(bss);  } -/* Fonction générique qui va traiter un fichier entier */ static int -process_file(char *name) +/* Fonction générique qui va traiter un fichier entier */ static int process_file(char *name)  {      FILE *f;      char buf[BUFSIZ], errctx[BUFSIZ], *p; @@ -4,9 +4,7 @@  #include "hash.h"  #include "exceptions.h"  #include "config.h" -static char *CHAINEHACHAGE = - -    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; +static char *CHAINEHACHAGE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";  static int FonctionHachage(char *clef)  { @@ -162,9 +160,7 @@ int Initialise(_TableauVariable * t)      unsigned int i; -    (*t) = -	(_TableauVariable) Emalloc(sizeof(_ListeChaine) * -				   (strlen(CHAINEHACHAGE) + 1)); +    (*t) = (_TableauVariable) Emalloc(sizeof(_ListeChaine) * (strlen(CHAINEHACHAGE) + 1));      for (i = 0; i <= strlen(CHAINEHACHAGE); i++) {  	(*t)[i] = NULL;      } diff --git a/lib/linker.c b/lib/linker.c index c66017c..b85cbb2 100644 --- a/lib/linker.c +++ b/lib/linker.c @@ -159,10 +159,8 @@ void addfile(char *nom)      objects[objindex]->datastart = datasize;      objects[objindex]->bssstart = bsssize; -    objects[objindex]->text = -	(Uint32 *) Emalloc(objects[objindex]->s_text * sizeof(Uint32)); -    objects[objindex]->data = -	(Uint32 *) Emalloc(objects[objindex]->s_data * sizeof(Uint32)); +    objects[objindex]->text = (Uint32 *) Emalloc(objects[objindex]->s_text * sizeof(Uint32)); +    objects[objindex]->data = (Uint32 *) Emalloc(objects[objindex]->s_data * sizeof(Uint32));      pushcontext(_("Reading text and data segments"));      for (i = 0; i < objects[objindex]->s_text; i++) { @@ -228,13 +226,10 @@ static void dumprelog(FILE * f)  		    decal = objects[t->objindex]->textstart + t->offset;  		    break;  		case 2: -		    decal = -			textsize + objects[t->objindex]->datastart + t->offset; +		    decal = textsize + objects[t->objindex]->datastart + t->offset;  		    break;  		case 4: -		    decal = -			textsize + datasize + -			objects[t->objindex]->bssstart + t->offset; +		    decal = textsize + datasize + objects[t->objindex]->bssstart + t->offset;  		    break;  		default:  		    exception(1, _("Internal error")); @@ -254,13 +249,10 @@ static void dumprelog(FILE * f)  		    decal = objects[t->objindex]->textstart + t->offset;  		    break;  		case 2: -		    decal = -			textsize + objects[t->objindex]->datastart + t->offset; +		    decal = textsize + objects[t->objindex]->datastart + t->offset;  		    break;  		case 4: -		    decal = -			textsize + datasize + -			objects[t->objindex]->bssstart + t->offset; +		    decal = textsize + datasize + objects[t->objindex]->bssstart + t->offset;  		    break;  		default:  		    exception(1, _("Internal error")); @@ -272,8 +264,7 @@ static void dumprelog(FILE * f)  			s->offset, decal, s->name);  #endif  		objects[s->objindex]->data[s->offset] += decal; -		writeword(textsize + -			  objects[s->objindex]->datastart + s->offset, f); +		writeword(textsize + objects[s->objindex]->datastart + s->offset, f);  		break;  	    default:  		exception(1, _("Internal error")); @@ -327,8 +318,7 @@ void dumpfile(char *nom)  	    textsize, datasize, bsssize);      fprintf(stderr,  	    _ -	    ("Output file size: %i words containing %i relocating offsets.\n"), -	    ftell(f), nbrsymbs); +	    ("Output file size: %i words containing %i relocating offsets.\n"), ftell(f) >> 2, nbrsymbs);      fclose(f);  } @@ -19,12 +19,8 @@  \*************************/  static char meta_ops[] = ":.;(){}[=, "; -static char meta_firsts[] = - -    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"; -static char meta_chars[] = - -    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"; +static char meta_firsts[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"; +static char meta_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789";  phon_t *phons = NULL;  field_t *fields = NULL; @@ -127,8 +123,7 @@ void meta_parse_line(char *line)  		    }  		    if (*line) {  			if (*line != ';') { -			    exception(1, -				      _("Expecting ';' for field separator.")); +			    exception(1, _("Expecting ';' for field separator."));  			}  			line++;  			gotname = 0; @@ -249,9 +244,7 @@ void meta_parse_line(char *line)  		    if (isident(buffer)) {  			p1 = Estrdup(buffer);  			if (*line != '=') { -			    exception(1, -				      _ -				      ("Expecting operator '=' for field 'p'.")); +			    exception(1, _("Expecting operator '=' for field 'p'."));  			}  			line++;  		    } else { @@ -345,9 +338,8 @@ void meta_parse_line(char *line)  			instruct->strings = (char **)  			    Emalloc(nbfields * sizeof(char *)); -			instruct->etypes = +			instruct->etypes = (int *) Emalloc(nbfields * sizeof(int)); -			    (int *) Emalloc(nbfields * sizeof(int));  			instruct->implicits = (char **)  			    Emalloc(nbimplicit * sizeof(char *)); @@ -598,11 +590,9 @@ void main(void)      fprintf(stderr, "\nListe des champs:\n");      for (field = fields->next; field; field = field->next) { -	fprintf(stderr, " o Champ nommé %s, contenant %i parties:\n", -		field->name, field->nbr); +	fprintf(stderr, " o Champ nommé %s, contenant %i parties:\n", field->name, field->nbr);  	for (i = 0; i < field->nbr; i++) { -	    fprintf(stderr, "   + %s (%i bits)\n", field->names[i], -		    field->sizes[i]); +	    fprintf(stderr, "   + %s (%i bits)\n", field->names[i], field->sizes[i]);  	}      } @@ -613,33 +603,26 @@ void main(void)  		pattern->name, pattern->nbr);  	for (i = 0; i < pattern->nbr; i++) {  	    fprintf(stderr, "    + %s (%s) type: %s\n", -		    pattern->expr[i]->name ? pattern-> -		    expr[i]->name : "Opérateur [", -		    pattern->expr[i]->string ? pattern-> -		    expr[i]->string : "Aucune chaîne associée", -		    pattern-> -		    expr[i]->type ? "Constante prédéfinie" : pattern->expr[i]-> -		    left ? "Binaire" : pattern-> -		    expr[i]->right ? "Unaire" : "Feuille"); +		    pattern->expr[i]->name ? pattern->expr[i]->name : "Opérateur [", +		    pattern->expr[i]->string ? pattern->expr[i]->string : "Aucune chaîne associée", +		    pattern->expr[i]->type ? "Constante prédéfinie" : pattern-> +		    expr[i]->left ? "Binaire" : pattern->expr[i]->right ? "Unaire" : "Feuille");  	    if (pattern->expr[i]->left) {  		fprintf(stderr,  			"      - gauche: %s (%s) type: %s\n", -			pattern->expr[i]->left->name ? pattern->expr[i]->left-> -			name : "Opérateur [", -			pattern->expr[i]->left->string ? pattern->expr[i]-> -			left->string : "Aucune chaîne associée", -			pattern->expr[i]-> -			left->type ? "Constante prédéfinie" : "Feuille"); +			pattern->expr[i]->left->name ? pattern->expr[i]->left->name : "Opérateur [", +			pattern->expr[i]->left->string ? pattern->expr[i]->left-> +			string : "Aucune chaîne associée", +			pattern->expr[i]->left->type ? "Constante prédéfinie" : "Feuille");  	    }  	    if (pattern->expr[i]->right) {  		fprintf(stderr,  			"      - droite: %s (%s) type: %s\n", -			pattern->expr[i]->right->name ? pattern->expr[i]-> -			right->name : "Opérateur [", -			pattern->expr[i]->right->string ? pattern->expr[i]-> -			right->string : "Aucune chaîne associée", -			pattern->expr[i]-> -			right->type ? "Constante prédéfinie" : "Feuille"); +			pattern->expr[i]->right->name ? pattern->expr[i]->right-> +			name : "Opérateur [", +			pattern->expr[i]->right->string ? pattern->expr[i]->right-> +			string : "Aucune chaîne associée", +			pattern->expr[i]->right->type ? "Constante prédéfinie" : "Feuille");  	    }  	}      } @@ -653,10 +636,8 @@ void main(void)  	for (i = 0; i < instruct->nbexplicit; i++) {  	    fprintf(stderr, "    + %s <= %s (type %s)\n",  		    instruct->names[i], -		    instruct-> -		    strings[i] ? instruct->strings[i] : -		    "Pas de chaîne associée", -		    instruct->etypes[i] ? "prédéfinit" : "direct"); +		    instruct->strings[i] ? instruct->strings[i] : +		    "Pas de chaîne associée", instruct->etypes[i] ? "prédéfinit" : "direct");  	}  	fprintf(stderr, "  => Champs implicites.\n");  	for (i = 0; i < instruct->nbimplicit; i++) { diff --git a/lib/parser.c b/lib/parser.c index cf2eab3..e5061a7 100644 --- a/lib/parser.c +++ b/lib/parser.c @@ -229,8 +229,7 @@ void parse_line(char *line)  		while (pileop_pos) {  		    op = pop_op();  		    if (op == '(') -			exception(-1, -				  _("Parse error: too much left parenthesis")); +			exception(-1, _("Parse error: too much left parenthesis"));  		    act_pile(get_func(op));  		}  		popcontext(); @@ -240,8 +239,7 @@ void parse_line(char *line)  		/* Fin de parenthese (Appel de fonction ou expression mathématique) */  		while (1) {  		    if (!pileop_pos) -			exception(-1, -				  _("Parse error: too much right parenthesis")); +			exception(-1, _("Parse error: too much right parenthesis"));  		    op = pop_op();  		    if (((op & 127) == '('))  			break; @@ -261,8 +259,7 @@ void parse_line(char *line)  		/* Fin d'opérateur de décalage */  		while (1) {  		    if (!pileop_pos) -			exception(-1, -				  _("Parse error: too much right parenthesis")); +			exception(-1, _("Parse error: too much right parenthesis"));  		    op = pop_op();  		    if (((op & 127) == '['))  			break; diff --git a/lib/simulator.c b/lib/simulator.c index 1bfdcd2..ea3b142 100644 --- a/lib/simulator.c +++ b/lib/simulator.c @@ -58,8 +58,7 @@ Uint32 Adresse(Uint32 u, Uint32 instruction)      switch (champ(u, 4)) {      case 0: -	exception(1, -		  _("Adresse: Call With Invalid r/m Field State ( r/m=00 )")); +	exception(1, _("Adresse: Call With Invalid r/m Field State ( r/m=00 )"));  	return (0);      case 1:  	tmp = LireInstruction(); @@ -228,13 +227,10 @@ void DecodeExec(Uint32 instruction)  	    if (ValeurBit(Extension(instruction), 1) == 0) {	/* Mov arg1 arg2 */  		if (ValeurBit(Extension(instruction), 0) == 0) {	/* arg2 = reg */  		    if (champ(Champ1(instruction), 2) == 0) {	/* r/m de arg1 = 0 */ -			EcrireRegistre(Champ3 -				       (instruction), -				       LireRegistre(Champ2(instruction))); +			EcrireRegistre(Champ3(instruction), LireRegistre(Champ2(instruction)));  		    } else {  			ST(Adresse -			   (Champ1(instruction), -			    instruction), LireRegistre(Champ2(instruction))); +			   (Champ1(instruction), instruction), LireRegistre(Champ2(instruction)));  		    }  		} else {	/* arg2 = imm32 */  		    if (champ(Champ1(instruction), 2) == 0) {	/* r/m de arg1 = 0 */ @@ -249,19 +245,14 @@ void DecodeExec(Uint32 instruction)  	    } else {		/* mov arg2, arg1 */  		if (ValeurBit(Extension(instruction), 0) == 0) {	/* arg2 = reg */  		    if (champ(Champ1(instruction), 2) == 0) {	/* r/m de arg1 = 0 */ -			EcrireRegistre(Champ2 -				       (instruction), -				       LireRegistre(Champ3(instruction))); +			EcrireRegistre(Champ2(instruction), LireRegistre(Champ3(instruction)));  		    } else {  			EcrireRegistre(Champ2  				       (instruction), -				       LD(Adresse -					  (Champ1(instruction), instruction))); +				       LD(Adresse(Champ1(instruction), instruction)));  		    }  		} else {	/* arg2 = imm32 */ -		    exception(1, -			      _ -			      ("MOV: Memory to Memory Forbidden On This Type Of Processor")); +		    exception(1, _("MOV: Memory to Memory Forbidden On This Type Of Processor"));  		}  	    }  	  fin: @@ -279,26 +270,17 @@ void DecodeExec(Uint32 instruction)  		if (Champ1(instruction) == Champ2(instruction)) {  		    test1 = 1;  		} else { -		    test1 = -			LireRegistre(Champ1 -				     (instruction)) == -			LireRegistre(Champ2(instruction)); +		    test1 = LireRegistre(Champ1(instruction)) == LireRegistre(Champ2(instruction));  		}  		break;  	    case 1: -		test1 = -		    LireRegistre(Champ1(instruction)) != -		    LireRegistre(Champ2(instruction)); +		test1 = LireRegistre(Champ1(instruction)) != LireRegistre(Champ2(instruction));  		break;  	    case 2: -		test1 = -		    LireRegistre(Champ1(instruction)) < -		    LireRegistre(Champ2(instruction)); +		test1 = LireRegistre(Champ1(instruction)) < LireRegistre(Champ2(instruction));  		break;  	    case 3: -		test1 = -		    LireRegistre(Champ1(instruction)) <= -		    LireRegistre(Champ2(instruction)); +		test1 = LireRegistre(Champ1(instruction)) <= LireRegistre(Champ2(instruction));  		break;  	    }  	    switch (champ(Extension(instruction) >> 2, 4)) { @@ -348,8 +330,7 @@ void DecodeExec(Uint32 instruction)  	    if (ValeurBit(Extension(instruction), 0) == 0) {  		/* RET */  		of = LireRegistreFLAG(); -		EcrireRegistreSP(AdditionNonSigne -				 (LireRegistreSP(), Champ1(instruction))); +		EcrireRegistreSP(AdditionNonSigne(LireRegistreSP(), Champ1(instruction)));  		EcrireRegistreSP(AdditionNonSigne(LireRegistreSP(), 1));  		EcrireRegistrePC(LD(LireRegistreSP()));  		EcrireRegistreFLAG(of); @@ -424,8 +405,7 @@ void AfficheReg(void)		//  affiche reg  	fprintf(stderr, "\n");      }      fprintf(stderr, "Rg: %08lX  | Rd: %08lX | Flag: %08lX | PC: %08lX\n", -	    LireRegistreRG(), LireRegistreRD(), LireRegistreFLAG(), -	    LireRegistrePC()); +	    LireRegistreRG(), LireRegistreRD(), LireRegistreFLAG(), LireRegistrePC());  }  void Debogueur(void) @@ -441,8 +421,7 @@ void Debogueur(void)  		Opcode(instruction), Extension(instruction),  		Champ1(instruction), Champ2(instruction), Champ3(instruction));  	fprintf(stderr, "%08lX:%08lX - %08lX - %08lX > ", -		LireRegistrePC(), instruction, LD(LireRegistrePC() + 1), -		LD(LireRegistrePC() + 2)); +		LireRegistrePC(), instruction, LD(LireRegistrePC() + 1), LD(LireRegistrePC() + 2));  	switch (fgetc(input)) {  	case 'G': @@ -464,9 +443,7 @@ void Debogueur(void)  	    clearterm();  	    exception(1, _("Shutdown requested"));  	default: -	    fprintf(stderr, -		    _ -		    ("Help:\nG: go\nP: Proceed\nR: display registers\nQ: quit\n")); +	    fprintf(stderr, _("Help:\nG: go\nP: Proceed\nR: display registers\nQ: quit\n"));  	}      }  } @@ -528,8 +505,7 @@ void ChargeBinaire(char *filename)      }      for (i = 0; i < nr; i++) {	/* relogement */ -	ST(base_addr + relocation_table[i], -	   LD(base_addr + relocation_table[i]) + base_addr); +	ST(base_addr + relocation_table[i], LD(base_addr + relocation_table[i]) + base_addr);      }      free(relocation_table); | 
