--- hatari/src/uae-cpu/newcpu.c 2019/04/01 07:11:55 1.1.1.9 +++ hatari/src/uae-cpu/newcpu.c 2019/04/01 07:13:13 1.1.1.11 @@ -10,7 +10,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. */ -char NewCpu_rcsid[] = "Hatari $Id: newcpu.c,v 1.1.1.9 2019/04/01 07:11:55 root Exp $"; +const char NewCpu_rcsid[] = "Hatari $Id: newcpu.c,v 1.1.1.11 2019/04/01 07:13:13 root Exp $"; #include "sysdeps.h" #include "hatari-glue.h" @@ -18,6 +18,7 @@ char NewCpu_rcsid[] = "Hatari $Id: newcp #include "memory.h" #include "newcpu.h" #include "../includes/main.h" +#include "../includes/log.h" #include "../includes/m68000.h" #include "../includes/mfp.h" #include "../includes/tos.h" @@ -37,8 +38,8 @@ uaecptr last_addr_for_exception_3; /* Address that generated the exception */ uaecptr last_fault_for_exception_3; -int areg_byteinc[] = { 1,1,1,1,1,1,1,2 }; -int imm8_table[] = { 8,1,2,3,4,5,6,7 }; +const int areg_byteinc[] = { 1,1,1,1,1,1,1,2 }; +const int imm8_table[] = { 8,1,2,3,4,5,6,7 }; int movem_index1[256]; int movem_index2[256]; @@ -117,15 +118,15 @@ void build_cpufunctbl(void) { int i; unsigned long opcode; - struct cputbl *tbl = (cpu_level == 4 ? op_smalltbl_0_ff - : cpu_level == 3 ? op_smalltbl_1_ff - : cpu_level == 2 ? op_smalltbl_2_ff - : cpu_level == 1 ? op_smalltbl_3_ff - : ! cpu_compatible ? op_smalltbl_4_ff - : op_smalltbl_5_ff); + const struct cputbl *tbl = (cpu_level == 4 ? op_smalltbl_0_ff + : cpu_level == 3 ? op_smalltbl_1_ff + : cpu_level == 2 ? op_smalltbl_2_ff + : cpu_level == 1 ? op_smalltbl_3_ff + : ! cpu_compatible ? op_smalltbl_4_ff + : op_smalltbl_5_ff); - write_log ("Building CPU function table (%d %d %d).\n", - cpu_level, cpu_compatible, address_space_24); + Log_Printf(LOG_DEBUG, "Building CPU function table (%d %d %d).\n", + cpu_level, cpu_compatible, address_space_24); for (opcode = 0; opcode < 65536; opcode++) cpufunctbl[opcode] = op_illg_1; @@ -225,19 +226,21 @@ void init_m68k (void) read_table68k (); do_merges (); - write_log ("%d CPU functions\n", nr_cpuop_funcs); + Log_Printf(LOG_DEBUG, "%d CPU functions\n", nr_cpuop_funcs); build_cpufunctbl (); } -struct regstruct regs, lastint_regs; /* not used ATM: static struct regstruct regs_backup[16]; static int backup_pointer = 0; +struct regstruct lastint_regs; +int lastint_no; */ +struct regstruct regs; static long int m68kpc_offset; -int lastint_no; + #define get_ibyte_1(o) get_byte(regs.pc + (regs.pc_p - regs.pc_oldp) + (o) + 1) #define get_iword_1(o) get_word(regs.pc + (regs.pc_p - regs.pc_oldp) + (o)) @@ -784,12 +787,12 @@ void Exception(int nr, uaecptr oldpc) if (bBusErrorReadWrite) specialstatus |= 0x10; put_word (m68k_areg(regs, 7), specialstatus); - put_long (m68k_areg(regs, 7)+2, BusAddressLocation); + put_long (m68k_areg(regs, 7)+2, BusErrorAddress); put_word (m68k_areg(regs, 7)+6, get_word(BusErrorPC)); /* Opcode */ /* Check for double bus errors: */ if (regs.spcflags & SPCFLAG_BUSERROR) { fprintf(stderr, "Detected double bus error at address $%x, PC=$%lx => CPU halted!\n", - BusAddressLocation, (long)currpc); + BusErrorAddress, (long)currpc); unset_special(SPCFLAG_BUSERROR); if (bEnableDebug) DebugUI(); @@ -797,8 +800,8 @@ void Exception(int nr, uaecptr oldpc) m68k_setstopped(TRUE); return; } - if (bEnableDebug && BusAddressLocation!=0xff8a00) { - fprintf(stderr,"Bus Error at address $%x, PC=$%lx\n",BusAddressLocation,(long)currpc); + if (bEnableDebug && BusErrorAddress!=0xff8a00) { + fprintf(stderr,"Bus Error at address $%x, PC=$%lx\n", BusErrorAddress, (long)currpc); DebugUI(); } } @@ -848,8 +851,8 @@ void Exception(int nr, uaecptr oldpc) static void Interrupt(int nr) { assert(nr < 8 && nr >= 0); - lastint_regs = regs; - lastint_no = nr; + /*lastint_regs = regs;*/ + /*lastint_no = nr;*/ Exception(nr+24, 0); regs.intmask = nr; @@ -932,12 +935,12 @@ int m68k_movec2 (int regno, uae_u32 *reg } STATIC_INLINE int -div_unsigned(uae_u32 src_hi, uae_u32 src_lo, uae_u32 div, uae_u32 *quot, uae_u32 *rem) +div_unsigned(uae_u32 src_hi, uae_u32 src_lo, uae_u32 ndiv, uae_u32 *quot, uae_u32 *rem) { uae_u32 q = 0, cbit = 0; int i; - if (div <= src_hi) { + if (ndiv <= src_hi) { return 1; } for (i = 0 ; i < 32 ; i++) { @@ -946,9 +949,9 @@ div_unsigned(uae_u32 src_hi, uae_u32 src if (src_lo & 0x80000000ul) src_hi++; src_lo <<= 1; q = q << 1; - if (cbit || div <= src_hi) { + if (cbit || ndiv <= src_hi) { q |= 1; - src_hi -= div; + src_hi -= ndiv; } } *quot = q; @@ -1296,7 +1299,7 @@ static int do_specialties (void) if(regs.spcflags & SPCFLAG_EXTRA_CYCLES) { /* Add some extra cycles to simulate a wait state */ unset_special(SPCFLAG_EXTRA_CYCLES); - M68000_AddCycles(4); + M68000_AddCycles(nWaitStateCycles); } if (regs.spcflags & SPCFLAG_DOTRACE) { @@ -1501,7 +1504,7 @@ static void m68k_verify (uaecptr addr, u void m68k_disasm (FILE *f, uaecptr addr, uaecptr *nextpc, int cnt) { - static const char* ccnames[] = + static const char * const ccnames[] = { "T ","F ","HI","LS","CC","CS","NE","EQ", "VC","VS","PL","MI","GE","LT","GT","LE" }; @@ -1511,7 +1514,7 @@ void m68k_disasm (FILE *f, uaecptr addr, char instrname[20],*ccpt; int opwords; uae_u32 opcode; - struct mnemolookup *lookup; + const struct mnemolookup *lookup; struct instr *dp; fprintf (f, "%08lx: ", m68k_getpc () + m68kpc_offset); for (opwords = 0; opwords < 5; opwords++){