Line 129... |
Line 129... |
|
|
/* Generates a execute sequence for one instruction */
|
/* Generates a execute sequence for one instruction */
|
int output_function (FILE *fo, const char *func_name, int level)
|
int output_function (FILE *fo, const char *func_name, int level)
|
{
|
{
|
FILE *fi;
|
FILE *fi;
|
if ((fi = fopen (in_file, "rt")) == NULL) return 1;
|
if ((fi = fopen (in_file, "rt")) == NULL) {
|
|
printf("could not open file\n");
|
|
return 1;
|
|
};
|
while (!feof (fi)) {
|
while (!feof (fi)) {
|
char line[10000], *str = line;
|
char line[10000], *str = line;
|
fgets (str, sizeof (line), fi);
|
fgets (str, sizeof (line), fi);
|
line[sizeof(line) - 1] = 0;
|
line[sizeof(line) - 1] = 0;
|
if (strncmp (str, "INSTRUCTION (", 13) == 0) {
|
if (strncmp (str, "INSTRUCTION (", 13) == 0) {
|
Line 163... |
Line 166... |
for (str = line; *str; str++) {
|
for (str = line; *str; str++) {
|
str = replace_operands (fo, str);
|
str = replace_operands (fo, str);
|
}
|
}
|
SHIFT;
|
SHIFT;
|
} while (olevel);
|
} while (olevel);
|
|
fclose(fi);
|
return 0;
|
return 0;
|
}
|
}
|
}
|
}
|
}
|
}
|
fprintf (fo, "{\n");
|
fprintf (fo, "{\n");
|
level++;
|
level++;
|
SHIFT; fprintf (fo, "%s ();\n", func_name);
|
SHIFT; fprintf (fo, "%s ();\n", func_name);
|
level--;
|
level--;
|
SHIFT; fprintf (fo, "}");
|
SHIFT; fprintf (fo, "}");
|
|
|
|
fclose(fi);
|
return 0;
|
return 0;
|
}
|
}
|
|
|
/* Parses and puts operands into op[] structure.
|
/* Parses and puts operands into op[] structure.
|
Replacement for eval_operands routine. */
|
Replacement for eval_operands routine. */
|
Line 268... |
Line 274... |
}
|
}
|
SHIFT; fprintf (fo, "analysis(current);\n");
|
SHIFT; fprintf (fo, "analysis(current);\n");
|
level--;
|
level--;
|
SHIFT; fprintf (fo, "}\n");
|
SHIFT; fprintf (fo, "}\n");
|
if (write_to_reg) {
|
if (write_to_reg) {
|
SHIFT; fprintf (fo, "reg[0] = 0; /* Repair in case we changed it */\n", i);
|
SHIFT; fprintf (fo, "reg[0] = 0; /* Repair in case we changed it */\n");
|
}
|
}
|
level--;
|
level--;
|
SHIFT; fprintf (fo, "}");
|
SHIFT; fprintf (fo, "}");
|
return 0;
|
return 0;
|
}
|
}
|
Line 341... |
Line 347... |
|
|
if (ti[i].insn_mask != cur_mask) {
|
if (ti[i].insn_mask != cur_mask) {
|
fprintf (fo, "\n");
|
fprintf (fo, "\n");
|
SHIFT; fprintf (fo, "/* Not unique: real mask %08x and current mask %08x differ - do final check */\n", ti[i].insn_mask, cur_mask);
|
SHIFT; fprintf (fo, "/* Not unique: real mask %08x and current mask %08x differ - do final check */\n", ti[i].insn_mask, cur_mask);
|
SHIFT; fprintf (fo, "if ((insn & 0x%08x) == 0x%08x) ", ti[i].insn_mask, ti[i].insn);
|
SHIFT; fprintf (fo, "if ((insn & 0x%08x) == 0x%08x) ", ti[i].insn_mask, ti[i].insn);
|
output_call (fo, i, level);
|
if (output_call (fo, i, level)) return 1; // Fail
|
fprintf (fo, " else ");
|
fprintf (fo, " else ");
|
if (output_call (fo, -1, level)) return 1;
|
if (output_call (fo, -1, level)) return 1; // Fail
|
} else {
|
} else {
|
output_call (fo, i, level - 1);
|
if (output_call (fo, i, level - 1)) return 1; // Fail
|
}
|
}
|
fprintf (fo, " break;\n");
|
fprintf (fo, " break;\n");
|
}
|
}
|
return 0;
|
return 0;
|
}
|
}
|