--- hatari/src/uae-cpu/gencpu.c 2019/04/01 07:10:40 1.1.1.4 +++ hatari/src/uae-cpu/gencpu.c 2019/04/01 07:13:11 1.1.1.7 @@ -22,7 +22,7 @@ * This file is distributed under the GNU Public License, version 2 or at * your option any later version. Read the file gpl.txt for details. */ -static char rcsid[] = "Hatari $Id: gencpu.c,v 1.1.1.4 2019/04/01 07:10:40 root Exp $"; +const char GenCpu_rcsid[] = "Hatari $Id: gencpu.c,v 1.1.1.7 2019/04/01 07:13:11 root Exp $"; #include #include @@ -46,17 +46,12 @@ char exactCpuCycles[256]; /* Space to * Initialized to -1 for each opcode. If it remains unchanged, indicates we * are done with that opcode. */ static int next_cpu_level; - -void write_log (const char *s, ...) -{ - fprintf (stderr, "%s", s); -} - static int *opcode_map; static int *opcode_next_clev; static int *opcode_last_postfix; static unsigned long *counts; + static void read_counts (void) { FILE *file; @@ -1351,7 +1346,6 @@ static void gen_opcode (unsigned long in insn_n_cycles = 20; break; case i_RTD: - printf ("\tcompiler_flush_jsr_stack();\n"); genamode (Aipi, "7", sz_long, "pc", 1, 0); genamode (curi->smode, "srcreg", curi->size, "offs", 1, 0); printf ("\tm68k_areg(regs, 7) += offs;\n"); @@ -1386,7 +1380,6 @@ static void gen_opcode (unsigned long in need_endlabel = 1; break; case i_RTR: - printf ("\tcompiler_flush_jsr_stack();\n"); printf ("\tMakeSR();\n"); genamode (Aipi, "7", sz_word, "sr", 1, 0); genamode (Aipi, "7", sz_long, "pc", 1, 0); @@ -1469,11 +1462,7 @@ static void gen_opcode (unsigned long in printf ("\t}\n"); need_endlabel = 1; } -#ifdef USE_COMPILER - printf ("\tm68k_setpc_bcc(m68k_getpc() + 2 + (uae_s32)src);\n"); -#else printf ("\tm68k_incpc ((uae_s32)src + 2);\n"); -#endif fill_prefetch_0 (); printf ("\treturn 10;\n"); printf ("didnt_jump:;\n"); @@ -1484,22 +1473,29 @@ static void gen_opcode (unsigned long in genamode (curi->smode, "srcreg", curi->size, "src", 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 2, 0); genastore ("srca", curi->dmode, "dstreg", curi->size, "dst"); - if(curi->smode==Ad8r || curi->smode==PC8r) - insn_n_cycles += 2; + /* Set correct cycles: According to the M68K User Manual, LEA takes 12 + * cycles in Ad8r and PC8r mode, but it takes 14 (or 16) cycles on a real ST: */ + if (curi->smode == Ad8r || curi->smode == PC8r) + insn_n_cycles = 14; break; case i_PEA: genamode (curi->smode, "srcreg", curi->size, "src", 0, 0); genamode (Apdi, "7", sz_long, "dst", 2, 0); genastore ("srca", Apdi, "7", sz_long, "dst"); + /* Set correct cycles: */ switch(curi->smode) { case Aind: insn_n_cycles=12; break; case Ad16: insn_n_cycles=16; break; - case Ad8r: insn_n_cycles=20; break; + /* Note: according to the M68K User Manual, PEA takes 20 cycles for + * the Ad8r mode, but on a real ST, it takes 22 (or 24) cycles! */ + case Ad8r: insn_n_cycles=22; break; case absw: insn_n_cycles=16; break; case absl: insn_n_cycles=20; break; case PC16: insn_n_cycles=16; break; - case PC8r: insn_n_cycles=20; break; + /* Note: PEA with PC8r takes 20 cycles according to the User Manual, + * but it takes 22 (or 24) cycles on a real ST: */ + case PC8r: insn_n_cycles=22; break; } break; case i_DBcc: @@ -1518,11 +1514,7 @@ static void gen_opcode (unsigned long in printf ("\t\t}\n"); need_endlabel = 1; } -#ifdef USE_COMPILER - printf ("\t\t\tm68k_setpc_bcc(m68k_getpc() + (uae_s32)offs + 2);\n"); -#else printf ("\t\t\tm68k_incpc((uae_s32)offs + 2);\n"); -#endif fill_prefetch_0 (); printf ("\t\t\treturn 10;\n"); printf ("\t\t} else {\n\t\t\t"); @@ -2404,7 +2396,6 @@ static void generate_includes (FILE * f) fprintf (f, "#include \"maccess.h\"\n"); fprintf (f, "#include \"memory.h\"\n"); fprintf (f, "#include \"newcpu.h\"\n"); - fprintf (f, "#include \"compiler.h\"\n"); fprintf (f, "#include \"cputbl.h\"\n"); fprintf (f, "#define CPUFUNC(x) x##_ff\n" "#ifdef NOFLAGS\n" @@ -2546,7 +2537,7 @@ static void generate_func (void) } postfix = i; - fprintf (stblfile, "struct cputbl CPUFUNC(op_smalltbl_%d)[] = {\n", postfix); + fprintf (stblfile, "const struct cputbl CPUFUNC(op_smalltbl_%d)[] = {\n", postfix); /* sam: this is for people with low memory (eg. me :)) */ printf ("\n"