X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Fmusashi%2Fm68kmake.c;h=361481b98efb0ec0567850e6ab565b0030412dc9;hb=a39743e3153322ec0e18bb0d05cd16af1d9a6d79;hp=d7cbc37355fc1a001d6bbecd65f54a0662da2b83;hpb=cc68a136aa179a5f32fe40208371eb9c2b0aadae;p=picodrive.git diff --git a/cpu/musashi/m68kmake.c b/cpu/musashi/m68kmake.c index d7cbc37..361481b 100644 --- a/cpu/musashi/m68kmake.c +++ b/cpu/musashi/m68kmake.c @@ -3,10 +3,10 @@ /* ======================================================================== */ /* * MUSASHI - * Version 3.3 + * Version 3.31 * * A portable Motorola M680x0 processor emulation engine. - * Copyright 1998-2001 Karl Stenerud. All rights reserved. + * Copyright 1998-2007 Karl Stenerud. All rights reserved. * * This code may be freely used for non-commercial purposes as long as this * copyright notice remains unaltered in the source code and any binary files @@ -52,7 +52,7 @@ */ -const char* g_version = "3.3"; +static const char* g_version = "3.31"; /* ======================================================================== */ /* =============================== INCLUDES =============================== */ @@ -88,9 +88,6 @@ const char* g_version = "3.3"; #define FILENAME_INPUT "m68k_in.c" #define FILENAME_PROTOTYPE "m68kops.h" #define FILENAME_TABLE "m68kops.c" -#define FILENAME_OPS_AC "m68kopac.c" -#define FILENAME_OPS_DM "m68kopdm.c" -#define FILENAME_OPS_NZ "m68kopnz.c" /* Identifier sequences recognized by this program */ @@ -240,7 +237,7 @@ void set_opcode_struct(opcode_struct* src, opcode_struct* dst, int ea_mode); void generate_opcode_handler(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* opinfo, int ea_mode); void generate_opcode_ea_variants(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* op); void generate_opcode_cc_variants(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* op_in, int offset); -void process_opcode_handlers(void); +void process_opcode_handlers(FILE* filep); void populate_table(void); void read_insert(char* insert); @@ -257,9 +254,6 @@ char g_input_filename[M68K_MAX_PATH] = FILENAME_INPUT; FILE* g_input_file = NULL; FILE* g_prototype_file = NULL; FILE* g_table_file = NULL; -FILE* g_ops_ac_file = NULL; -FILE* g_ops_dm_file = NULL; -FILE* g_ops_nz_file = NULL; int g_num_functions = 0; /* Number of functions processed */ int g_num_primitives = 0; /* Number of function primitives read */ @@ -481,9 +475,6 @@ void error_exit(const char* fmt, ...) if(g_prototype_file) fclose(g_prototype_file); if(g_table_file) fclose(g_table_file); - if(g_ops_ac_file) fclose(g_ops_ac_file); - if(g_ops_dm_file) fclose(g_ops_dm_file); - if(g_ops_nz_file) fclose(g_ops_nz_file); if(g_input_file) fclose(g_input_file); exit(EXIT_FAILURE); @@ -500,9 +491,6 @@ void perror_exit(const char* fmt, ...) if(g_prototype_file) fclose(g_prototype_file); if(g_table_file) fclose(g_table_file); - if(g_ops_ac_file) fclose(g_ops_ac_file); - if(g_ops_dm_file) fclose(g_ops_dm_file); - if(g_ops_nz_file) fclose(g_ops_nz_file); if(g_input_file) fclose(g_input_file); exit(EXIT_FAILURE); @@ -1001,10 +989,9 @@ void generate_opcode_cc_variants(FILE* filep, body_struct* body, replace_struct* } /* Process the opcode handlers section of the input file */ -void process_opcode_handlers(void) +void process_opcode_handlers(FILE* filep) { FILE* input_file = g_input_file; - FILE* output_file; char func_name[MAX_LINE_LENGTH+1]; char oper_name[MAX_LINE_LENGTH+1]; int oper_size; @@ -1014,9 +1001,6 @@ void process_opcode_handlers(void) replace_struct* replace = malloc(sizeof(replace_struct)); body_struct* body = malloc(sizeof(body_struct)); - - output_file = g_ops_ac_file; - for(;;) { /* Find the first line of the function */ @@ -1059,23 +1043,22 @@ void process_opcode_handlers(void) if(opinfo == NULL) error_exit("Unable to find matching table entry for %s", func_name); - /* Change output files if we pass 'c' or 'n' */ - if(output_file == g_ops_ac_file && oper_name[0] > 'c') - output_file = g_ops_dm_file; - else if(output_file == g_ops_dm_file && oper_name[0] > 'm') - output_file = g_ops_nz_file; +#if 1 /* PD hack: 000 only */ + if (opinfo->cpus[0] == UNSPECIFIED_CH) + continue; +#endif replace->length = 0; /* Generate opcode variants */ if(strcmp(opinfo->name, "bcc") == 0 || strcmp(opinfo->name, "scc") == 0) - generate_opcode_cc_variants(output_file, body, replace, opinfo, 1); + generate_opcode_cc_variants(filep, body, replace, opinfo, 1); else if(strcmp(opinfo->name, "dbcc") == 0) - generate_opcode_cc_variants(output_file, body, replace, opinfo, 2); + generate_opcode_cc_variants(filep, body, replace, opinfo, 2); else if(strcmp(opinfo->name, "trapcc") == 0) - generate_opcode_cc_variants(output_file, body, replace, opinfo, 4); + generate_opcode_cc_variants(filep, body, replace, opinfo, 4); else - generate_opcode_ea_variants(output_file, body, replace, opinfo); + generate_opcode_ea_variants(filep, body, replace, opinfo); } free(replace); @@ -1248,7 +1231,9 @@ int main(int argc, char **argv) /* Inserts */ char temp_insert[MAX_INSERT_LENGTH+1]; char prototype_footer_insert[MAX_INSERT_LENGTH+1]; + char table_header_insert[MAX_INSERT_LENGTH+1]; char table_footer_insert[MAX_INSERT_LENGTH+1]; + char ophandler_header_insert[MAX_INSERT_LENGTH+1]; char ophandler_footer_insert[MAX_INSERT_LENGTH+1]; /* Flags if we've processed certain parts already */ int prototype_header_read = 0; @@ -1260,8 +1245,8 @@ int main(int argc, char **argv) int table_body_read = 0; int ophandler_body_read = 0; - printf("\n\t\tMusashi v%s 68000, 68008, 68010, 68EC020, 68020 emulator\n", g_version); - printf("\t\tCopyright 1998-2000 Karl Stenerud (karl@mame.net)\n\n"); + printf("\n\tMusashi v%s 68000, 68008, 68010, 68EC020, 68020, 68040 emulator\n", g_version); + printf("\tCopyright 1998-2007 Karl Stenerud (karl@mame.net)\n\n"); /* Check if output path and source for the input file are given */ if(argc > 1) @@ -1293,18 +1278,6 @@ int main(int argc, char **argv) if((g_table_file = fopen(filename, "w")) == NULL) perror_exit("Unable to create table file (%s)\n", filename); - sprintf(filename, "%s%s", output_path, FILENAME_OPS_AC); - if((g_ops_ac_file = fopen(filename, "w")) == NULL) - perror_exit("Unable to create ops ac file (%s)\n", filename); - - sprintf(filename, "%s%s", output_path, FILENAME_OPS_DM); - if((g_ops_dm_file = fopen(filename, "w")) == NULL) - perror_exit("Unable to create ops dm file (%s)\n", filename); - - sprintf(filename, "%s%s", output_path, FILENAME_OPS_NZ); - if((g_ops_nz_file = fopen(filename, "w")) == NULL) - perror_exit("Unable to create ops nz file (%s)\n", filename); - if((g_input_file=fopen(g_input_filename, "r")) == NULL) perror_exit("can't open %s for input", g_input_filename); @@ -1320,18 +1293,6 @@ int main(int argc, char **argv) if((g_table_file = fopen(filename, "wt")) == NULL) perror_exit("Unable to create table file (%s)\n", filename); - sprintf(filename, "%s%s", output_path, FILENAME_OPS_AC); - if((g_ops_ac_file = fopen(filename, "wt")) == NULL) - perror_exit("Unable to create ops ac file (%s)\n", filename); - - sprintf(filename, "%s%s", output_path, FILENAME_OPS_DM); - if((g_ops_dm_file = fopen(filename, "wt")) == NULL) - perror_exit("Unable to create ops dm file (%s)\n", filename); - - sprintf(filename, "%s%s", output_path, FILENAME_OPS_NZ); - if((g_ops_nz_file = fopen(filename, "wt")) == NULL) - perror_exit("Unable to create ops nz file (%s)\n", filename); - if((g_input_file=fopen(g_input_filename, "rt")) == NULL) perror_exit("can't open %s for input", g_input_filename); @@ -1360,18 +1321,14 @@ int main(int argc, char **argv) { if(table_header_read) error_exit("Duplicate table header"); - read_insert(temp_insert); - fprintf(g_table_file, "%s", temp_insert); + read_insert(table_header_insert); table_header_read = 1; } else if(strcmp(section_id, ID_OPHANDLER_HEADER) == 0) { if(ophandler_header_read) error_exit("Duplicate opcode handler header"); - read_insert(temp_insert); - fprintf(g_ops_ac_file, "%s\n\n", temp_insert); - fprintf(g_ops_dm_file, "%s\n\n", temp_insert); - fprintf(g_ops_nz_file, "%s\n\n", temp_insert); + read_insert(ophandler_header_insert); ophandler_header_read = 1; } else if(strcmp(section_id, ID_PROTOTYPE_FOOTER) == 0) @@ -1424,7 +1381,9 @@ int main(int argc, char **argv) if(ophandler_body_read) error_exit("Duplicate opcode handler section"); - process_opcode_handlers(); + fprintf(g_table_file, "%s\n\n", ophandler_header_insert); + process_opcode_handlers(g_table_file); + fprintf(g_table_file, "%s\n\n", ophandler_footer_insert); ophandler_body_read = 1; } @@ -1448,13 +1407,11 @@ int main(int argc, char **argv) if(!ophandler_body_read) error_exit("Missing opcode handler body"); + fprintf(g_table_file, "%s\n\n", table_header_insert); print_opcode_output_table(g_table_file); + fprintf(g_table_file, "%s\n\n", table_footer_insert); fprintf(g_prototype_file, "%s\n\n", prototype_footer_insert); - fprintf(g_table_file, "%s\n\n", table_footer_insert); - fprintf(g_ops_ac_file, "%s\n\n", ophandler_footer_insert); - fprintf(g_ops_dm_file, "%s\n\n", ophandler_footer_insert); - fprintf(g_ops_nz_file, "%s\n\n", ophandler_footer_insert); break; } @@ -1467,9 +1424,6 @@ int main(int argc, char **argv) /* Close all files and exit */ fclose(g_prototype_file); fclose(g_table_file); - fclose(g_ops_ac_file); - fclose(g_ops_dm_file); - fclose(g_ops_nz_file); fclose(g_input_file); printf("Generated %d opcode handlers from %d primitives\n", g_num_functions, g_num_primitives);