From: Toni Wilen Date: Sat, 17 Nov 2018 16:01:13 +0000 (+0200) Subject: 68030 MMU MOVEM update and cleanup X-Git-Tag: 4100~32 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=42fb0547c7f6f88c448d4c5f47cfef7c69d8375c;p=francis%2Fwinuae.git 68030 MMU MOVEM update and cleanup --- diff --git a/fpp.cpp b/fpp.cpp index b1531d02..c68de15e 100644 --- a/fpp.cpp +++ b/fpp.cpp @@ -2492,10 +2492,6 @@ static uaecptr fmovem2fpp (uaecptr ad, uae_u32 list, int incr, int regdir) uae_u32 wrd[3]; int idx = 0; mmu030_state[1] |= MMU030_STATEFLAG1_MOVEM1 | MMU030_STATEFLAG1_FMOVEM; - if (mmu030_state[1] & MMU030_STATEFLAG1_MOVEM2) - ad = mmu030_ad[mmu030_idx].val; - else - mmu030_ad[mmu030_idx].val = ad; for (int r = 0; r < 8; r++) { if (regdir < 0) reg = 7 - r; diff --git a/gencpu.cpp b/gencpu.cpp index b2186173..bf94c3b6 100644 --- a/gencpu.cpp +++ b/gencpu.cpp @@ -2178,10 +2178,8 @@ static void movem_mmu030 (const char *code, int size, bool put, bool aipi, bool printf ("\tint movem_cnt = 0;\n"); if (!put) { printf ("\tuae_u32 val;\n"); - printf ("\tif (mmu030_state[1] & MMU030_STATEFLAG1_MOVEM2)\n"); - printf ("\t\tsrca = mmu030_ad[mmu030_idx].val;\n"); - printf ("\telse\n"); - printf ("\t\tmmu030_ad[mmu030_idx].val = srca;\n"); + // Store original EA because MOVEM from memory may modify same register + printf ("\tsrca = state_store_mmu030(srca);\n"); } for (int i = 0; i < 2; i++) { char reg; diff --git a/include/cpummu030.h b/include/cpummu030.h index b5f52d9d..f1114e6e 100644 --- a/include/cpummu030.h +++ b/include/cpummu030.h @@ -588,6 +588,20 @@ STATIC_INLINE uae_u32 next_ilong_mmu030 (void) return v; } +STATIC_INLINE uae_u32 state_store_mmu030(uae_u32 v) +{ + if (mmu030_ad[mmu030_idx].done) { + v = mmu030_ad[mmu030_idx].val; + mmu030_idx++; + } else { + mmu030_ad[mmu030_idx].val = v; + mmu030_ad[mmu030_idx].done = true; + mmu030_idx++; + mmu030_ad[mmu030_idx].done = false; + } + return v; +} + extern void m68k_do_rts_mmu030 (void); extern void m68k_do_rte_mmu030 (uaecptr a7); extern void flush_mmu030 (uaecptr, int); diff --git a/include/mmu_common.h b/include/mmu_common.h index c2768c9f..3a14495e 100644 --- a/include/mmu_common.h +++ b/include/mmu_common.h @@ -108,7 +108,7 @@ typedef int m68k_exception; #define ALWAYS_INLINE __inline -// take care of 2 kinds of alignement, bus size and page +// take care of 2 kinds of alignment, bus size and page #if 1 static ALWAYS_INLINE bool is_unaligned(uaecptr addr, int size) { diff --git a/newcpu.cpp b/newcpu.cpp index 784628b3..ab40d278 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -3190,7 +3190,7 @@ static void Exception_build_stack_frame (uae_u32 oldpc, uae_u32 currpc, uae_u32 x_put_long (m68k_areg (regs, 7), mmu030_disp_store[0]); m68k_areg (regs, 7) -= 4; // Data output buffer = value that was going to be written - x_put_long (m68k_areg (regs, 7), (mmu030_state[1] & MMU030_STATEFLAG1_MOVEM1) ? mmu030_data_buffer : mmu030_ad[mmu030_idx].val); + x_put_long (m68k_areg (regs, 7), mmu030_data_buffer); m68k_areg (regs, 7) -= 4; x_put_long (m68k_areg (regs, 7), (mmu030_opcode & 0xffff) | (regs.prefetch020[0] << 16)); // Internal register (opcode storage) m68k_areg (regs, 7) -= 4;