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 d10v_opcode
*opcode
;
27 for (opcode
= (struct d10v_opcode
*)d10v_opcodes
; opcode
->name
; opcode
++)
28 if (opcode
->format
!= OPCODE_FAKE
)
29 printf("void OP_%X PARAMS ((void));\t\t/* %s */\n",opcode
->opcode
, opcode
->name
);
33 /* write_template creates a file all required functions, ready */
34 /* to be filled out */
39 struct d10v_opcode
*opcode
;
42 printf ("#include \"d10v_sim.h\"\n");
43 printf ("#include \"simops.h\"\n");
45 for (opcode
= (struct d10v_opcode
*)d10v_opcodes
; opcode
->name
; opcode
++)
47 if (opcode
->format
!= OPCODE_FAKE
)
49 printf("/* %s */\nvoid\nOP_%X ()\n{\n",opcode
->name
,opcode
->opcode
);
55 int flags
= d10v_operands
[opcode
->operands
[i
]].flags
;
56 if ((flags
& OPERAND_REG
) || (flags
& OPERAND_NUM
) || (flags
& OPERAND_ADDR
))
62 printf ("printf(\" %s\\n\");\n",opcode
->name
);
65 printf ("printf(\" %s\\t%%x\\n\",OP[0]);\n",opcode
->name
);
68 printf ("printf(\" %s\\t%%x,%%x\\n\",OP[0],OP[1]);\n",opcode
->name
);
71 printf ("printf(\" %s\\t%%x,%%x,%%x\\n\",OP[0],OP[1],OP[2]);\n",opcode
->name
);
74 fprintf (stderr
,"Too many operands: %d\n",j
);
85 check_opcodes( long op
)
91 fprintf(stderr
,"DUPLICATE OPCODES: %x\n",op
);
98 struct d10v_opcode
*opcode
;
101 /* write out opcode table */
102 printf ("#include \"d10v_sim.h\"\n");
103 printf ("#include \"simops.h\"\n\n");
104 printf ("struct simops Simops[] = {\n");
106 for (opcode
= (struct d10v_opcode
*)d10v_opcodes
; opcode
->name
; opcode
++)
108 if (opcode
->format
!= OPCODE_FAKE
)
110 printf (" { %ld,%d,%ld,%d,%d,%d,%d,OP_%X,", opcode
->opcode
,
111 (opcode
->format
& LONG_OPCODE
) ? 1 : 0, opcode
->mask
, opcode
->format
,
112 opcode
->cycles
, opcode
->unit
, opcode
->exec_type
, opcode
->opcode
);
115 check_opcodes (opcode
->opcode
);
116 Opcodes
[curop
++] = opcode
->opcode
;
121 int flags
= d10v_operands
[opcode
->operands
[i
]].flags
;
122 if ((flags
& OPERAND_REG
) || (flags
& OPERAND_NUM
) || (flags
& OPERAND_ADDR
))
130 int flags
= d10v_operands
[opcode
->operands
[i
]].flags
;
131 int shift
= d10v_operands
[opcode
->operands
[i
]].shift
;
132 if ((flags
& OPERAND_REG
) || (flags
& OPERAND_NUM
)|| (flags
& OPERAND_ADDR
))
136 if ((flags
& OPERAND_REG
) && (opcode
->format
== LONG_L
))
138 printf ("%d,%d,%d",shift
,d10v_operands
[opcode
->operands
[i
]].bits
,flags
);
145 printf ("{ 0,0,0,0,0,0,NULL,0,{ }},\n};\n");