start new makefile, migrate to libpicofe
[picodrive.git] / cpu / Cyclone / OpMove.cpp
index ac2abea..78adae5 100644 (file)
@@ -121,16 +121,18 @@ int OpMove(int op)
 \r
   OpStart(op,sea,tea); Cycles=4;\r
 \r
-  EaCalcRead(-1,1,sea,size,0x003f);\r
-\r
   if (movea==0)\r
   {\r
-    ot("  adds r1,r1,#0 ;@ Defines NZ, clears CV\n");\r
+    EaCalcRead(-1,0,sea,size,0x003f);\r
+    ot("  adds r1,r0,#0 ;@ Defines NZ, clears CV\n");\r
     ot("  mrs r10,cpsr ;@ r10=NZCV flags\n");\r
     ot("\n");\r
   }\r
-\r
-  if (movea) size=2; // movea always expands to 32-bits\r
+  else\r
+  {\r
+    EaCalcRead(-1,1,sea,size,0x003f);\r
+    size=2; // movea always expands to 32-bits\r
+  }\r
 \r
   eawrite_check_addrerr=1;\r
 #if SPLIT_MOVEL_PD\r
@@ -149,8 +151,8 @@ int OpMove(int op)
   }\r
 \r
 #if CYCLONE_FOR_GENESIS && !MEMHANDLERS_CHANGE_CYCLES\r
-  // this is a bit hacky\r
-  if ((tea==0x39||(tea>=0x10&&tea<0x30))&&size>=1)\r
+  // this is a bit hacky (device handlers might modify cycles)\r
+  if (tea==0x39||((0x10<=tea&&tea<0x30)&&size>=1))\r
     ot("  ldr r5,[r7,#0x5c] ;@ Load Cycles\n");\r
 #endif\r
 \r
@@ -376,23 +378,20 @@ int OpMovem(int op)
 \r
   OpStart(op,ea,0,1);\r
 \r
+  ot("  ldrh r11,[r4],#2 ;@ r11=register mask\n");\r
+  ot("\n");\r
+  ot(";@ Get the address into r6:\n");\r
+  EaCalc(6,0x003f,cea,size);\r
+\r
 #if !MEMHANDLERS_NEED_PREV_PC\r
   // must save PC, need a spare register\r
   ot("  str r4,[r7,#0x40] ;@ Save PC\n");\r
 #endif\r
-#if !MEMHANDLERS_NEED_CYCLES\r
-  ot("  str r5,[r7,#0x5c] ;@ Save Cycles\n");\r
-#endif\r
-  ot("  ldrh r11,[r4],#2 ;@ r11=register mask\n");\r
 \r
   ot(";@ r4=Register Index*4:\n");\r
   if (decr) ot("  mov r4,#0x40 ;@ order reversed for -(An)\n");\r
   else      ot("  mov r4,#-4\n");\r
   \r
-  ot("\n");\r
-  ot(";@ Get the address into r6:\n");\r
-  EaCalc(6,0x003f,cea,size);\r
-\r
   ot("\n");\r
   ot("  tst r11,r11\n");        // sanity check\r
   ot("  beq NoRegs%.4x\n",op);\r