4 #include "opcode/v850.h"
7 static void write_header PARAMS ((void));
8 static void write_opcodes PARAMS ((void));
9 static void write_template PARAMS ((void));
19 if ((argc > 1) && (strcmp (argv[1], "-h") == 0))
21 else if ((argc > 1) && (strcmp (argv[1], "-t") == 0))
32 struct v850_opcode *opcode;
34 for (opcode = (struct v850_opcode *)v850_opcodes; opcode->name; opcode++)
35 printf("int OP_%X PARAMS ((void));\t\t/* %s */\n",
36 opcode->opcode, opcode->name);
40 /* write_template creates a file all required functions, ready */
41 /* to be filled out */
46 struct v850_opcode *opcode;
49 printf ("#include \"sim-main.h\"\n");
50 printf ("#include \"v850_sim.h\"\n");
51 printf ("#include \"simops.h\"\n");
53 for (opcode = (struct v850_opcode *)v850_opcodes; opcode->name; opcode++)
55 printf("/* %s */\nvoid\nOP_%X (void)\n{\n", opcode->name, opcode->opcode);
59 for (i = 0; i < 6; i++)
61 int flags = v850_operands[opcode->operands[i]].flags;
63 if (flags & (V850_OPERAND_REG | V850_OPERAND_SRG | V850_OPERAND_CC))
69 printf ("printf(\" %s\\n\");\n", opcode->name);
72 printf ("printf(\" %s\\t%%x\\n\", OP[0]);\n", opcode->name);
75 printf ("printf(\" %s\\t%%x,%%x\\n\",OP[0],OP[1]);\n",
79 printf ("printf(\" %s\\t%%x,%%x,%%x\\n\",OP[0],OP[1],OP[2]);\n",
83 fprintf (stderr,"Too many operands: %d\n", j);
92 struct v850_opcode *opcode;
96 /* write out opcode table */
97 printf ("#include \"sim-main.h\"\n");
98 printf ("#include \"v850_sim.h\"\n");
99 printf ("#include \"simops.h\"\n\n");
100 printf ("struct simops Simops[] = {\n");
102 for (opcode = (struct v850_opcode *)v850_opcodes; opcode->name; opcode++)
104 printf (" { 0x%x,0x%x,OP_%X,",
105 opcode->opcode, opcode->mask, opcode->opcode);
107 Opcodes[curop++] = opcode->opcode;
111 for (i = 0; i < 6; i++)
113 int flags = v850_operands[opcode->operands[i]].flags;
115 if (flags & (V850_OPERAND_REG | V850_OPERAND_SRG | V850_OPERAND_CC))
122 for (i = 0; i < 6; i++)
124 int flags = v850_operands[opcode->operands[i]].flags;
125 int shift = v850_operands[opcode->operands[i]].shift;
127 if (flags & (V850_OPERAND_REG | V850_OPERAND_SRG | V850_OPERAND_CC))
131 printf ("%d,%d,%d", shift,
132 v850_operands[opcode->operands[i]].bits,flags);
148 printf ("{ 0,0,NULL,0,{0,0,0,0,0,0}},\n};\n");