/* ======================================================================== */\r
/*\r
* MUSASHI\r
- * Version 3.3\r
+ * Version 3.31\r
*\r
* A portable Motorola M680x0 processor emulation engine.\r
- * Copyright 1998-2001 Karl Stenerud. All rights reserved.\r
+ * Copyright 1998-2007 Karl Stenerud. All rights reserved.\r
*\r
* This code may be freely used for non-commercial purposes as long as this\r
* copyright notice remains unaltered in the source code and any binary files\r
*/\r
\r
\r
-const char* g_version = "3.3";\r
+static const char* g_version = "3.31";\r
\r
/* ======================================================================== */\r
/* =============================== INCLUDES =============================== */\r
#define FILENAME_INPUT "m68k_in.c"\r
#define FILENAME_PROTOTYPE "m68kops.h"\r
#define FILENAME_TABLE "m68kops.c"\r
-#define FILENAME_OPS_AC "m68kopac.c"\r
-#define FILENAME_OPS_DM "m68kopdm.c"\r
-#define FILENAME_OPS_NZ "m68kopnz.c"\r
\r
\r
/* Identifier sequences recognized by this program */\r
void generate_opcode_handler(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* opinfo, int ea_mode);\r
void generate_opcode_ea_variants(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* op);\r
void generate_opcode_cc_variants(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* op_in, int offset);\r
-void process_opcode_handlers(void);\r
+void process_opcode_handlers(FILE* filep);\r
void populate_table(void);\r
void read_insert(char* insert);\r
\r
FILE* g_input_file = NULL;\r
FILE* g_prototype_file = NULL;\r
FILE* g_table_file = NULL;\r
-FILE* g_ops_ac_file = NULL;\r
-FILE* g_ops_dm_file = NULL;\r
-FILE* g_ops_nz_file = NULL;\r
\r
int g_num_functions = 0; /* Number of functions processed */\r
int g_num_primitives = 0; /* Number of function primitives read */\r
\r
if(g_prototype_file) fclose(g_prototype_file);\r
if(g_table_file) fclose(g_table_file);\r
- if(g_ops_ac_file) fclose(g_ops_ac_file);\r
- if(g_ops_dm_file) fclose(g_ops_dm_file);\r
- if(g_ops_nz_file) fclose(g_ops_nz_file);\r
if(g_input_file) fclose(g_input_file);\r
\r
exit(EXIT_FAILURE);\r
\r
if(g_prototype_file) fclose(g_prototype_file);\r
if(g_table_file) fclose(g_table_file);\r
- if(g_ops_ac_file) fclose(g_ops_ac_file);\r
- if(g_ops_dm_file) fclose(g_ops_dm_file);\r
- if(g_ops_nz_file) fclose(g_ops_nz_file);\r
if(g_input_file) fclose(g_input_file);\r
\r
exit(EXIT_FAILURE);\r
}\r
\r
/* Process the opcode handlers section of the input file */\r
-void process_opcode_handlers(void)\r
+void process_opcode_handlers(FILE* filep)\r
{\r
FILE* input_file = g_input_file;\r
- FILE* output_file;\r
char func_name[MAX_LINE_LENGTH+1];\r
char oper_name[MAX_LINE_LENGTH+1];\r
int oper_size;\r
replace_struct* replace = malloc(sizeof(replace_struct));\r
body_struct* body = malloc(sizeof(body_struct));\r
\r
-\r
- output_file = g_ops_ac_file;\r
-\r
for(;;)\r
{\r
/* Find the first line of the function */\r
if(opinfo == NULL)\r
error_exit("Unable to find matching table entry for %s", func_name);\r
\r
- /* Change output files if we pass 'c' or 'n' */\r
- if(output_file == g_ops_ac_file && oper_name[0] > 'c')\r
- output_file = g_ops_dm_file;\r
- else if(output_file == g_ops_dm_file && oper_name[0] > 'm')\r
- output_file = g_ops_nz_file;\r
+#if 1 /* PD hack: 000 only */\r
+ if (opinfo->cpus[0] == UNSPECIFIED_CH)\r
+ continue;\r
+#endif\r
\r
replace->length = 0;\r
\r
/* Generate opcode variants */\r
if(strcmp(opinfo->name, "bcc") == 0 || strcmp(opinfo->name, "scc") == 0)\r
- generate_opcode_cc_variants(output_file, body, replace, opinfo, 1);\r
+ generate_opcode_cc_variants(filep, body, replace, opinfo, 1);\r
else if(strcmp(opinfo->name, "dbcc") == 0)\r
- generate_opcode_cc_variants(output_file, body, replace, opinfo, 2);\r
+ generate_opcode_cc_variants(filep, body, replace, opinfo, 2);\r
else if(strcmp(opinfo->name, "trapcc") == 0)\r
- generate_opcode_cc_variants(output_file, body, replace, opinfo, 4);\r
+ generate_opcode_cc_variants(filep, body, replace, opinfo, 4);\r
else\r
- generate_opcode_ea_variants(output_file, body, replace, opinfo);\r
+ generate_opcode_ea_variants(filep, body, replace, opinfo);\r
}\r
\r
free(replace);\r
/* Inserts */\r
char temp_insert[MAX_INSERT_LENGTH+1];\r
char prototype_footer_insert[MAX_INSERT_LENGTH+1];\r
+ char table_header_insert[MAX_INSERT_LENGTH+1];\r
char table_footer_insert[MAX_INSERT_LENGTH+1];\r
+ char ophandler_header_insert[MAX_INSERT_LENGTH+1];\r
char ophandler_footer_insert[MAX_INSERT_LENGTH+1];\r
/* Flags if we've processed certain parts already */\r
int prototype_header_read = 0;\r
int table_body_read = 0;\r
int ophandler_body_read = 0;\r
\r
- printf("\n\t\tMusashi v%s 68000, 68008, 68010, 68EC020, 68020 emulator\n", g_version);\r
- printf("\t\tCopyright 1998-2000 Karl Stenerud (karl@mame.net)\n\n");\r
+ printf("\n\tMusashi v%s 68000, 68008, 68010, 68EC020, 68020, 68040 emulator\n", g_version);\r
+ printf("\tCopyright 1998-2007 Karl Stenerud (karl@mame.net)\n\n");\r
\r
/* Check if output path and source for the input file are given */\r
if(argc > 1)\r
if((g_table_file = fopen(filename, "w")) == NULL)\r
perror_exit("Unable to create table file (%s)\n", filename);\r
\r
- sprintf(filename, "%s%s", output_path, FILENAME_OPS_AC);\r
- if((g_ops_ac_file = fopen(filename, "w")) == NULL)\r
- perror_exit("Unable to create ops ac file (%s)\n", filename);\r
-\r
- sprintf(filename, "%s%s", output_path, FILENAME_OPS_DM);\r
- if((g_ops_dm_file = fopen(filename, "w")) == NULL)\r
- perror_exit("Unable to create ops dm file (%s)\n", filename);\r
-\r
- sprintf(filename, "%s%s", output_path, FILENAME_OPS_NZ);\r
- if((g_ops_nz_file = fopen(filename, "w")) == NULL)\r
- perror_exit("Unable to create ops nz file (%s)\n", filename);\r
-\r
if((g_input_file=fopen(g_input_filename, "r")) == NULL)\r
perror_exit("can't open %s for input", g_input_filename);\r
\r
if((g_table_file = fopen(filename, "wt")) == NULL)\r
perror_exit("Unable to create table file (%s)\n", filename);\r
\r
- sprintf(filename, "%s%s", output_path, FILENAME_OPS_AC);\r
- if((g_ops_ac_file = fopen(filename, "wt")) == NULL)\r
- perror_exit("Unable to create ops ac file (%s)\n", filename);\r
-\r
- sprintf(filename, "%s%s", output_path, FILENAME_OPS_DM);\r
- if((g_ops_dm_file = fopen(filename, "wt")) == NULL)\r
- perror_exit("Unable to create ops dm file (%s)\n", filename);\r
-\r
- sprintf(filename, "%s%s", output_path, FILENAME_OPS_NZ);\r
- if((g_ops_nz_file = fopen(filename, "wt")) == NULL)\r
- perror_exit("Unable to create ops nz file (%s)\n", filename);\r
-\r
if((g_input_file=fopen(g_input_filename, "rt")) == NULL)\r
perror_exit("can't open %s for input", g_input_filename);\r
\r
{\r
if(table_header_read)\r
error_exit("Duplicate table header");\r
- read_insert(temp_insert);\r
- fprintf(g_table_file, "%s", temp_insert);\r
+ read_insert(table_header_insert);\r
table_header_read = 1;\r
}\r
else if(strcmp(section_id, ID_OPHANDLER_HEADER) == 0)\r
{\r
if(ophandler_header_read)\r
error_exit("Duplicate opcode handler header");\r
- read_insert(temp_insert);\r
- fprintf(g_ops_ac_file, "%s\n\n", temp_insert);\r
- fprintf(g_ops_dm_file, "%s\n\n", temp_insert);\r
- fprintf(g_ops_nz_file, "%s\n\n", temp_insert);\r
+ read_insert(ophandler_header_insert);\r
ophandler_header_read = 1;\r
}\r
else if(strcmp(section_id, ID_PROTOTYPE_FOOTER) == 0)\r
if(ophandler_body_read)\r
error_exit("Duplicate opcode handler section");\r
\r
- process_opcode_handlers();\r
+ fprintf(g_table_file, "%s\n\n", ophandler_header_insert);\r
+ process_opcode_handlers(g_table_file);\r
+ fprintf(g_table_file, "%s\n\n", ophandler_footer_insert);\r
\r
ophandler_body_read = 1;\r
}\r
if(!ophandler_body_read)\r
error_exit("Missing opcode handler body");\r
\r
+ fprintf(g_table_file, "%s\n\n", table_header_insert);\r
print_opcode_output_table(g_table_file);\r
+ fprintf(g_table_file, "%s\n\n", table_footer_insert);\r
\r
fprintf(g_prototype_file, "%s\n\n", prototype_footer_insert);\r
- fprintf(g_table_file, "%s\n\n", table_footer_insert);\r
- fprintf(g_ops_ac_file, "%s\n\n", ophandler_footer_insert);\r
- fprintf(g_ops_dm_file, "%s\n\n", ophandler_footer_insert);\r
- fprintf(g_ops_nz_file, "%s\n\n", ophandler_footer_insert);\r
\r
break;\r
}\r
/* Close all files and exit */\r
fclose(g_prototype_file);\r
fclose(g_table_file);\r
- fclose(g_ops_ac_file);\r
- fclose(g_ops_dm_file);\r
- fclose(g_ops_nz_file);\r
fclose(g_input_file);\r
\r
printf("Generated %d opcode handlers from %d primitives\n", g_num_functions, g_num_primitives);\r