1 #include "mn10200_sim.h"
3 static void write_header PARAMS ((void));
4 static void write_opcodes PARAMS ((void));
5 static void write_template PARAMS ((void));
12 if ((argc > 1) && (strcmp (argv[1], "-h") == 0))
14 else if ((argc > 1) && (strcmp (argv[1], "-t") == 0))
25 struct mn10200_opcode *opcode;
27 for (opcode = (struct mn10200_opcode *)mn10200_opcodes; opcode->name; opcode++)
28 printf("void OP_%X PARAMS ((unsigned long, unsigned long));\t\t/* %s */\n",
29 opcode->opcode, opcode->name);
33 /* write_template creates a file all required functions, ready */
34 /* to be filled out */
39 struct mn10200_opcode *opcode;
42 printf ("#include \"mn10200_sim.h\"\n");
43 printf ("#include \"simops.h\"\n");
45 for (opcode = (struct mn10200_opcode *)mn10200_opcodes; opcode->name; opcode++)
47 printf("/* %s */\nvoid\nOP_%X (insn, extension)\n unsigned long insn, extension;\n{\n", opcode->name, opcode->opcode);
51 for (i = 0; i < 6; i++)
53 int flags = mn10200_operands[opcode->operands[i]].flags;
61 printf ("printf(\" %s\\n\");\n", opcode->name);
64 printf ("printf(\" %s\\t%%x\\n\", OP[0]);\n", opcode->name);
67 printf ("printf(\" %s\\t%%x,%%x\\n\",OP[0],OP[1]);\n",
71 printf ("printf(\" %s\\t%%x,%%x,%%x\\n\",OP[0],OP[1],OP[2]);\n",
75 fprintf (stderr,"Too many operands: %d\n", j);
84 struct mn10200_opcode *opcode;
88 /* write out opcode table */
89 printf ("#include \"mn10200_sim.h\"\n");
90 printf ("#include \"simops.h\"\n\n");
91 printf ("struct simops Simops[] = {\n");
93 for (opcode = (struct mn10200_opcode *)mn10200_opcodes; opcode->name; opcode++)
97 if (opcode->format == FMT_1)
99 else if (opcode->format == FMT_2 || opcode->format == FMT_4)
101 else if (opcode->format == FMT_3 || opcode->format == FMT_5)
103 else if (opcode->format == FMT_6)
105 else if (opcode->format == FMT_7)
110 printf (" { 0x%x,0x%x,OP_%X,%d,%d,",
111 opcode->opcode, opcode->mask, opcode->opcode,
112 size, opcode->format);
116 for (i = 0; i < 6; i++)
118 int flags = mn10200_operands[opcode->operands[i]].flags;
127 for (i = 0; i < 6; i++)
129 int flags = mn10200_operands[opcode->operands[i]].flags;
130 int shift = mn10200_operands[opcode->operands[i]].shift;
136 printf ("%d,%d,%d", shift,
137 mn10200_operands[opcode->operands[i]].bits,flags);
153 printf ("{ 0,0,NULL,0,0,0,{0,0,0,0,0,0}},\n};\n");