--- nono/m680x0/m68030core.h 2026/04/29 17:04:28 1.1 +++ nono/m680x0/m68030core.h 2026/04/29 17:04:34 1.1.1.2 @@ -1,6 +1,7 @@ // // nono -// Copyright (C) 2017 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once @@ -19,6 +20,7 @@ extern void m68030_restore_reg_pd(m68kcp extern void m68030_set_sr(m68kcpu *, uint16); 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_rte(m68kcpu *); extern const char *m68030_get_exception_name(int); @@ -58,7 +60,7 @@ m68k_add_cycle_nc(m68kcpu *cpu, int cc, // cc はキャッシュケース、ncc はノーキャッシュケースのサイクル。 // ncc は cc からの差分ではなく、ノーキャッシュケースの時のサイクル数 // そのものを指定する。(内部で差分をとっている) -#define CYCLE2(cc, ncc) m68k_add_cycle_nc(cpu, (cc), (ncc)); +#define CYCLE2(cc, ncc) m68k_add_cycle_nc(cpu, (cc), (ncc)) // PC を addr に変更する。 // addr がメモリからの入力の場合アドレスエラーのチェックが必要なため。 @@ -71,24 +73,10 @@ m68030_jump(m68kcpu *cpu, uint32 addr) return; } - RegPC = addr; - // ブランチ履歴 - m68kbrhist *h = &cpu->brhist[cpu->brhist_top]; -//printf("jump PPC=%x addr=%x h.from=%x to=%x", RegPPC, addr, h->from, h->to); - if (h->from == RegPPC && h->to == addr) { - // 前回と同じなら通過回数++ - h->count++; -//printf(" ++\n"); - } else { - // そうでなければ、新規エントリ - cpu->brhist_top++; -//printf(" [%d]\n", cpu->brhist_top); - h = &cpu->brhist[cpu->brhist_top]; - h->from = RegPPC; - h->to = addr; - h->count = 1; - } + cpu->brhist.AddEntry(RegPPC, addr); + + RegPC = addr; } // -(An) 実行前にレジスタを保存する。 @@ -159,9 +147,10 @@ cond_func(m68kcpu *cpu, int cond) // 副作用のあるマクロ // 特権違反例外のスタックに積む PC は違反を起こした命令先頭。 -#define SUPERVISOR_OP \ +#define SUPERVISOR_OP do { \ if (!RegIsS) { \ CYCLE2(18, 20); \ m68030_exception(cpu, M68K_EXCEP_PRIV); \ return; \ - } + } \ +} while (0)