--- hatari/src/uae-cpu/gencpu.c 2019/04/01 07:10:59 1.1.1.5 +++ 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.5 2019/04/01 07:10:59 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; @@ -1478,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: @@ -2535,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"