1 #include "mn10300_sim.h"
3 static void write_header
PARAMS ((void));
4 static void write_opcodes
PARAMS ((void));
5 static void write_template
PARAMS ((void));
15 if ((argc
> 1) && (strcmp (argv
[1], "-h") == 0))
17 else if ((argc
> 1) && (strcmp (argv
[1], "-t") == 0))
28 struct mn10300_opcode
*opcode
;
30 for (opcode
= (struct mn10300_opcode
*)mn10300_opcodes
; opcode
->name
; opcode
++)
31 printf("void OP_%X PARAMS ((unsigned long, unsigned long));\t\t/* %s */\n",
32 opcode
->opcode
, opcode
->name
);
36 /* write_template creates a file all required functions, ready */
37 /* to be filled out */
42 struct mn10300_opcode
*opcode
;
45 printf ("#include \"mn10300_sim.h\"\n");
46 printf ("#include \"simops.h\"\n");
48 for (opcode
= (struct mn10300_opcode
*)mn10300_opcodes
; opcode
->name
; opcode
++)
50 printf("/* %s */\nvoid\nOP_%X (insn, extension)\n unsigned long insn, extension;\n{\n", opcode
->name
, opcode
->opcode
);
54 for (i
= 0; i
< 6; i
++)
56 int flags
= mn10300_operands
[opcode
->operands
[i
]].flags
;
64 printf ("printf(\" %s\\n\");\n", opcode
->name
);
67 printf ("printf(\" %s\\t%%x\\n\", OP[0]);\n", opcode
->name
);
70 printf ("printf(\" %s\\t%%x,%%x\\n\",OP[0],OP[1]);\n",
74 printf ("printf(\" %s\\t%%x,%%x,%%x\\n\",OP[0],OP[1],OP[2]);\n",
78 fprintf (stderr
,"Too many operands: %d\n", j
);
87 struct mn10300_opcode
*opcode
;
91 /* write out opcode table */
92 printf ("#include \"mn10300_sim.h\"\n");
93 printf ("#include \"simops.h\"\n\n");
94 printf ("struct simops Simops[] = {\n");
96 for (opcode
= (struct mn10300_opcode
*)mn10300_opcodes
; opcode
->name
; opcode
++)
100 if (opcode
->format
== FMT_S0
)
102 else if (opcode
->format
== FMT_S1
103 || opcode
->format
== FMT_D0
)
105 else if (opcode
->format
== FMT_S2
106 || opcode
->format
== FMT_D1
)
108 else if (opcode
->format
== FMT_S4
)
110 else if (opcode
->format
== FMT_D2
)
112 else if (opcode
->format
== FMT_D4
)
117 printf (" { 0x%x,0x%x,OP_%X,%d,%d,",
118 opcode
->opcode
, opcode
->mask
, opcode
->opcode
,
119 size
, opcode
->format
);
121 Opcodes
[curop
++] = opcode
->opcode
;
125 for (i
= 0; i
< 6; i
++)
127 int flags
= mn10300_operands
[opcode
->operands
[i
]].flags
;
136 for (i
= 0; i
< 6; i
++)
138 int flags
= mn10300_operands
[opcode
->operands
[i
]].flags
;
139 int shift
= mn10300_operands
[opcode
->operands
[i
]].shift
;
145 printf ("%d,%d,%d", shift
,
146 mn10300_operands
[opcode
->operands
[i
]].bits
,flags
);
162 printf ("{ 0,0,NULL,0,0,0,{0,0,0,0,0,0}},\n};\n");