]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
JIT indirect/safe mode MOVEM.W bug fix.
authorToni Wilen <twilen@winuae.net>
Sat, 18 Dec 2021 17:45:33 +0000 (19:45 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 18 Dec 2021 17:45:33 +0000 (19:45 +0200)
include/memory.h
jit/compemu.h
jit/compemu_prefs.cpp
jit/gencomp.cpp
memory.cpp
newcpu.cpp

index 2b16f90701761ac7a35728242a3f7f9a64b7c868..c7520a25ced6fffa190cf040a49172acc0b721d4 100644 (file)
@@ -15,6 +15,7 @@ extern void a1000_reset(void);
 
 #ifdef JIT
 extern int special_mem;
+extern int special_mem_default;
 extern int jit_n_addr_unsafe;
 #endif
 
index 70f76dcd957a450023a4f6ba8eb2a338c41a9568..93fd4e87dfc758e9207c4f6622eb48597cf8352e 100644 (file)
@@ -524,9 +524,6 @@ extern void compile_block(cpu_history* pc_hist, int blocklen, int totcyles);
 #define MAXCYCLES (1000 * CYCLE_UNIT)
 #define scaled_cycles(x) (currprefs.m68k_speed<0?(((x)/SCALE)?(((x)/SCALE<MAXCYCLES?((x)/SCALE):MAXCYCLES)):1):(x))
 
-/* Flags for Bernie during development/debugging. Should go away eventually */
-#define DISTRUST_CONSISTENT_MEM 0
-
 struct op_properties {
        uae_u8 use_flags;
        uae_u8 set_flags;
index a54436ea13c8b67326bfab733289451ffd24d03f..ab11119cf80ba30b833a58c00090c008b707ab86 100644 (file)
@@ -9,6 +9,8 @@ bool check_prefs_changed_comp (bool checkonly)
        static int cachesize_prev, comptrust_prev;
        static bool canbang_prev;
 
+       special_mem_default = currprefs.comptrustbyte ? (S_READ | S_WRITE | S_N_ADDR) : 0;
+
        if (currprefs.comptrustbyte != changed_prefs.comptrustbyte ||
                currprefs.comptrustword != changed_prefs.comptrustword ||
                currprefs.comptrustlong != changed_prefs.comptrustlong ||
index 4142813ae9336beb0e48eaf783f46ac68868a208..862c6008055006c7a23ca835fe1c2b99480700e2 100644 (file)
@@ -64,7 +64,7 @@
  #define DISABLE_I_SWAP
  #define DISABLE_I_EXG
  #define DISABLE_I_EXT
- #define DISABLE_I_MVEL
+ #define DISABLE_I_MVMEL
  #define DISABLE_I_MVMLE
  #define DISABLE_I_RTD
  #define DISABLE_I_LINK
@@ -923,6 +923,7 @@ genmovemel(uae_u16 opcode)
                break;
        case sz_word:
                comprintf("\t\t\t\treadword(tmp,i,scratchie);\n"
+                       "\t\t\t\tsign_extend_16_rr(i,i);\n"
                        "\t\t\t\tadd_l_ri(tmp,2);\n");
                break;
        default: assert(0);
@@ -955,15 +956,18 @@ genmovemle(uae_u16 opcode)
           on her, but unfortunately, gfx mem isn't "real" mem, and thus that
           act of cleverness means that movmle must pay attention to special_mem,
           or Genetic Species is a rather boring-looking game ;-) */
-       if (table68k[opcode].size == sz_long)
-               comprintf("\tif (1 && !special_mem && !jit_n_addr_unsafe) {\n");
-       else
+       if (table68k[opcode].dmode != Apdi) {
                comprintf("\tif (1 && !special_mem && !jit_n_addr_unsafe) {\n");
+       } else {
+               // if Apdi and dstreg is included with mask: use indirect mode.
+               comprintf("\tif (1 && !special_mem && !jit_n_addr_unsafe && !(mask & (1 << (7 - dstreg)))) {\n");
+       }
 #endif
+
        comprintf("\tget_n_addr(srca,native,scratchie);\n");
 
        if (table68k[opcode].dmode != Apdi) {
-               comprintf("\tfor (i=0;i<16;i++) {\n"
+               comprintf("\tfor (i=0;i<16 && mask;i++) {\n"
                        "\t\tif ((mask>>i)&1) {\n");
                switch (table68k[opcode].size) {
                case sz_long:
@@ -981,7 +985,7 @@ genmovemle(uae_u16 opcode)
                default: assert(0);
                }
        } else {  /* Pre-decrement */
-               comprintf("\tfor (i=0;i<16;i++) {\n"
+               comprintf("\tfor (i=0;i<16 && mask;i++) {\n"
                        "\t\tif ((mask>>i)&1) {\n");
                switch (table68k[opcode].size) {
                case sz_long:
@@ -1002,7 +1006,6 @@ genmovemle(uae_u16 opcode)
                }
        }
 
-
        comprintf("\t\t}\n");
        comprintf("\t}\n");
        if (table68k[opcode].dmode == Apdi) {
@@ -1013,7 +1016,7 @@ genmovemle(uae_u16 opcode)
 
        if (table68k[opcode].dmode != Apdi) {
                comprintf("\tmov_l_rr(tmp,srca);\n");
-               comprintf("\tfor (i=0;i<16;i++) {\n"
+               comprintf("\tfor (i=0;i<16 && mask;i++) {\n"
                        "\t\tif ((mask>>i)&1) {\n");
                switch (table68k[opcode].size) {
                case sz_long:
@@ -1027,7 +1030,7 @@ genmovemle(uae_u16 opcode)
                default: assert(0);
                }
        } else {  /* Pre-decrement */
-               comprintf("\tfor (i=0;i<16;i++) {\n"
+               comprintf("\tfor (i=0;i<16 && mask;i++) {\n"
                        "\t\tif ((mask>>i)&1) {\n");
                switch (table68k[opcode].size) {
                case sz_long:
@@ -1042,7 +1045,6 @@ genmovemle(uae_u16 opcode)
                }
        }
 
-
        comprintf("\t\t}\n");
        comprintf("\t}\n");
        if (table68k[opcode].dmode == Apdi) {
@@ -1841,7 +1843,7 @@ gen_opcode(unsigned int opcode)
                break;
 
        case i_MVMEL:
-#ifdef DISABLE_I_MVEL
+#ifdef DISABLE_I_MVMEL
                failure;
 #endif
                genmovemel(opcode);
index 686347fe8b002ba7f003b1924434bee82cb73c5e..fa8ac2126833533409f0237272fbf9dd81de525f 100644 (file)
@@ -47,7 +47,7 @@ bool canbang;
 static bool rom_write_enabled;
 #ifdef JIT
 /* Set by each memory handler that does not simply access real memory. */
-int special_mem;
+int special_mem, special_mem_default;
 /* do not use get_n_addr */
 int jit_n_addr_unsafe;
 #endif
index 4c286c6975cd8e5c1b5b01b98ea748033f6f09bd..f7d50ed28d2344026389c04a2bd45ad7ec009018 100644 (file)
@@ -5269,7 +5269,7 @@ void execute_normal(void)
                /* Take note: This is the do-it-normal loop */
                r->opcode = get_jit_opcode();
 
-               special_mem = DISTRUST_CONSISTENT_MEM;
+               special_mem = special_mem_default;
                pc_hist[blocklen].location = (uae_u16*)r->pc_p;
 
                (*cpufunctbl[r->opcode])(r->opcode);