7 #include "opcode/d10v.h"
9 static void write_header
PARAMS ((void));
10 static void write_opcodes
PARAMS ((void));
11 static void write_template
PARAMS ((void));
18 if ((argc
> 1) && (strcmp (argv
[1],"-h") == 0))
20 else if ((argc
> 1) && (strcmp (argv
[1],"-t") == 0))
31 struct d10v_opcode
*opcode
;
33 for (opcode
= (struct d10v_opcode
*)d10v_opcodes
; opcode
->name
; opcode
++)
34 if (opcode
->format
!= OPCODE_FAKE
)
35 printf("void OP_%X PARAMS ((void));\t\t/* %s */\n",opcode
->opcode
, opcode
->name
);
39 /* write_template creates a file all required functions, ready */
40 /* to be filled out */
45 struct d10v_opcode
*opcode
;
48 printf ("#include \"d10v_sim.h\"\n");
49 printf ("#include \"simops.h\"\n");
51 for (opcode
= (struct d10v_opcode
*)d10v_opcodes
; opcode
->name
; opcode
++)
53 if (opcode
->format
!= OPCODE_FAKE
)
55 printf("/* %s */\nvoid\nOP_%X ()\n{\n",opcode
->name
,opcode
->opcode
);
61 int flags
= d10v_operands
[opcode
->operands
[i
]].flags
;
62 if ((flags
& OPERAND_REG
) || (flags
& OPERAND_NUM
) || (flags
& OPERAND_ADDR
))
68 printf ("printf(\" %s\\n\");\n",opcode
->name
);
71 printf ("printf(\" %s\\t%%x\\n\",OP[0]);\n",opcode
->name
);
74 printf ("printf(\" %s\\t%%x,%%x\\n\",OP[0],OP[1]);\n",opcode
->name
);
77 printf ("printf(\" %s\\t%%x,%%x,%%x\\n\",OP[0],OP[1],OP[2]);\n",opcode
->name
);
80 fprintf (stderr
,"Too many operands: %d\n",j
);
91 check_opcodes( long op
)
97 fprintf(stderr
,"DUPLICATE OPCODES: %x\n",op
);
104 struct d10v_opcode
*opcode
;
107 /* write out opcode table */
108 printf ("#include \"d10v_sim.h\"\n");
109 printf ("#include \"simops.h\"\n\n");
110 printf ("struct simops Simops[] = {\n");
112 for (opcode
= (struct d10v_opcode
*)d10v_opcodes
; opcode
->name
; opcode
++)
114 if (opcode
->format
!= OPCODE_FAKE
)
116 printf (" { %ld,%d,%ld,%d,%d,%d,%d,OP_%X,", opcode
->opcode
,
117 (opcode
->format
& LONG_OPCODE
) ? 1 : 0, opcode
->mask
, opcode
->format
,
118 opcode
->cycles
, opcode
->unit
, opcode
->exec_type
, opcode
->opcode
);
121 check_opcodes (opcode
->opcode
);
122 Opcodes
[curop
++] = opcode
->opcode
;
127 int flags
= d10v_operands
[opcode
->operands
[i
]].flags
;
128 if ((flags
& OPERAND_REG
) || (flags
& OPERAND_NUM
) || (flags
& OPERAND_ADDR
))
136 int flags
= d10v_operands
[opcode
->operands
[i
]].flags
;
137 int shift
= d10v_operands
[opcode
->operands
[i
]].shift
;
138 if ((flags
& OPERAND_REG
) || (flags
& OPERAND_NUM
)|| (flags
& OPERAND_ADDR
))
144 if ((flags
& OPERAND_REG
) && (opcode
->format
== LONG_L
))
146 printf ("%d,%d,%d",shift
,d10v_operands
[opcode
->operands
[i
]].bits
,flags
);
155 printf ("{ 0,0,0,0,0,0,0,(void (*)(void))0,0,{0,0,0}},\n};\n");
This page took 0.035731 seconds and 5 git commands to generate.