--- nono/m680x0/m68030core.h 2026/04/29 17:04:34 1.1.1.2 +++ nono/m680x0/m68030core.h 2026/04/29 17:04:49 1.1.1.6 @@ -21,34 +21,28 @@ extern void m68030_set_sr(m68kcpu *, uin extern void m68030_exception(m68kcpu *, int); extern void m68030_exception_reset(m68kcpu *); extern void m68030_exception_buserr(m68kcpu *, int); -extern void m68030_exception_interrupt(m68kcpu *, int, int); +extern void m68030_exception_interrupt(m68kcpu *, int); extern void m68030_rte(m68kcpu *); -extern const char *m68030_get_exception_name(int); -static inline void cpulog(int lv, const char *fmt, ...) __printflike(2, 3); -static inline void -cpulog(int lv, const char *fmt, ...) -{ - if (__predict_false(gMPU->loglevel >= lv)) { - va_list ap; - va_start(ap, fmt); - gMPU->vputlog(fmt, ap); - va_end(ap); - } -} +// 文字列を作る前にレベルを評価するためマクロ +#define cpulog(lv, fmt...) do { \ + if (__predict_false(gMPU->loglevel >= (lv))) { \ + gMPU->putlogn(fmt); \ + } \ +} while (0) // ops 用のマクロとか static inline void m68k_add_cycle(m68kcpu *cpu, int cc) { - cpu->cycle_cache += cc; + cpu->used_cycle += cc; } static inline void m68k_add_cycle_nc(m68kcpu *cpu, int cc, int ncc) { - cpu->cycle_cache += cc; + cpu->used_cycle += cc; cpu->cycle_nocache += ncc - cc; } @@ -62,21 +56,26 @@ m68k_add_cycle_nc(m68kcpu *cpu, int cc, // そのものを指定する。(内部で差分をとっている) #define CYCLE2(cc, ncc) m68k_add_cycle_nc(cpu, (cc), (ncc)) +// アドレスエラーチェック +// (jump() と jump_vector() の2か所で必要なため) +#define CHECK_ADDRESS_ERROR(addr) do { \ + if (__predict_false(((addr) & 1) != 0)) { \ + m68030_exception(cpu, M68K_EXCEP_ADDRERR); \ + return; \ + } \ +} while (0) + // PC を addr に変更する。 // addr がメモリからの入力の場合アドレスエラーのチェックが必要なため。 +// ベクタへのジャンプはここではなく subr.cpp::m68030_jump_vector()。 static inline void m68030_jump(m68kcpu *cpu, uint32 addr) { - // アドレスエラーチェック - if (__predict_false((addr & 1) != 0)) { - m68030_exception(cpu, M68K_EXCEP_ADDRERR); - return; - } + CHECK_ADDRESS_ERROR(addr); + RegPC = addr; // ブランチ履歴 - cpu->brhist.AddEntry(RegPPC, addr); - - RegPC = addr; + cpu->brhist.AddEntry(RegPPC | (cpu->reg.s ? 1 : 0), addr, cpu->ir << 16); } // -(An) 実行前にレジスタを保存する。