adjustments for MAME
[picodrive.git] / cpu / Cyclone / OpArith.cpp
index 33cdf87..29b6cdf 100644 (file)
@@ -22,7 +22,7 @@ int OpArith(int op)
   use=OpBase(op);\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op); Cycles=4;\r
+  OpStart(op, sea|tea); Cycles=4;\r
 \r
   EaCalc(10,0x0000, sea,size,1);\r
   EaRead(10,    10, sea,size,0,1);\r
@@ -94,7 +94,7 @@ int OpAddq(int op)
   if (num!=8) use|=0x0e00; // If num is not 8, use same handler\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op);\r
+  OpStart(op,ea);\r
   Cycles=ea<8?4:8;\r
   if(type==0&&size==1) Cycles=ea<0x10?4:8;\r
   if(size>=2) Cycles=ea<0x10?8:12;\r
@@ -157,7 +157,7 @@ int OpArithReg(int op)
   use&=~0x0e00; // Use same opcode for Dn\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op); Cycles=4;\r
+  OpStart(op,ea); Cycles=4;\r
 \r
   ot(";@ Get r10=EA r11=EA value\n");\r
   EaCalc(10,0x003f, ea,size,1);\r
@@ -190,9 +190,9 @@ int OpArithReg(int op)
     if(size>=2) Cycles+=4;\r
   } else {\r
     if(size>=2) {\r
-         Cycles+=2;\r
-         if(ea<0x10||ea==0x3c) Cycles+=2;\r
-       }\r
+      Cycles+=2;\r
+      if(ea<0x10||ea==0x3c) Cycles+=2;\r
+    }\r
   }\r
 \r
   OpEnd();\r
@@ -219,7 +219,7 @@ int OpMul(int op)
   use&=~0x0e00; // Use same for all registers\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op);\r
+  OpStart(op,ea);\r
   if(type) Cycles=54;\r
   else     Cycles=sign?158:140;\r
 \r
@@ -249,10 +249,10 @@ int OpMul(int op)
       ot("\n");\r
     }\r
     else\r
-       {\r
+    {\r
       ot("  mov r10,r10,lsl #16 ;@ use only 16 bits of divisor\n");\r
       ot("  mov r10,r10,lsr #16\n");\r
-       }\r
+    }\r
 \r
     ot(";@ Divide r2 by r10\n");\r
     ot("  mov r3,#0\n");\r
@@ -277,7 +277,7 @@ int OpMul(int op)
 \r
     if (sign)\r
     {\r
-         // sign correction\r
+      // sign correction\r
       ot("  and r1,r11,#1\n");\r
       ot("  teq r1,r11,lsr #1\n");\r
       ot("  rsbne r3,r3,#0 ;@ negate if quotient is negative\n");\r
@@ -285,19 +285,19 @@ int OpMul(int op)
       ot("  rsbne r2,r2,#0 ;@ negate the remainder if divident was negative\n");\r
       ot("\n");\r
 \r
-         // signed overflow check\r
-         ot("  mov r1,r3,asl #16\n");\r
-         ot("  cmp r3,r1,asr #16 ;@ signed overflow?\n");\r
+      // signed overflow check\r
+      ot("  mov r1,r3,asl #16\n");\r
+      ot("  cmp r3,r1,asr #16 ;@ signed overflow?\n");\r
       ot("  orrne r9,r9,#0x10000000 ;@ set overflow flag\n");\r
       ot("  bne endofop%.4x ;@ overflow!\n",op);\r
     }\r
-       else\r
-       {\r
-         // overflow check\r
-         ot("  movs r1,r3,lsr #16 ;@ check for overflow condition\n");\r
+    else\r
+    {\r
+      // overflow check\r
+      ot("  movs r1,r3,lsr #16 ;@ check for overflow condition\n");\r
       ot("  orrne r9,r9,#0x10000000 ;@ set overflow flag\n");\r
       ot("  bne endofop%.4x ;@ overflow!\n",op);\r
-       }\r
+    }\r
 \r
     ot("  mov r1,r3,lsl #16 ;@ Clip to 16-bits\n");\r
     ot("  adds r1,r1,#0 ;@ Defines NZ, clears CV\n");\r
@@ -370,7 +370,7 @@ int OpAbcd(int op)
   if (sea==0x27||dea==0x27) use=op; // ..except -(a7)\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op); Cycles=6;\r
+  OpStart(op,sea|dea); Cycles=6;\r
 \r
   EaCalc( 0,0x0007, sea,0,1);\r
   EaRead( 0,    10, sea,0,0x0007,1);\r
@@ -384,7 +384,7 @@ int OpAbcd(int op)
     ot("  ldrb r0,[r7,#0x45] ;@ Get X bit\n");\r
     ot("  mov r3,#0x00f00000\n");\r
     ot("  and r2,r3,r1,lsr #4\n");\r
-       ot("  tst r0,#2\n");\r
+    ot("  tst r0,#2\n");\r
     ot("  and r0,r3,r10,lsr #4\n");\r
     ot("  add r0,r0,r2\n");\r
     ot("  addne r0,r0,#0x00100000\n");\r
@@ -398,20 +398,20 @@ int OpAbcd(int op)
     ot("  mov r2,r10,lsr #28\n");\r
     ot("  add r0,r0,r2,lsl #24\n");\r
     ot("  cmp r0,#0x09900000\n");\r
-       ot("  orrhi r9,r9,#0x20000000 ;@ C\n");\r
-       ot("  subhi r0,r0,#0x0a000000\n");\r
-//     ot("  and r3,r9,r0,lsr #3 ;@ Undefined V behavior part II\n");\r
-//     ot("  orr r9,r9,r3,lsl #4 ;@ V\n");\r
+    ot("  orrhi r9,r9,#0x20000000 ;@ C\n");\r
+    ot("  subhi r0,r0,#0x0a000000\n");\r
+//    ot("  and r3,r9,r0,lsr #3 ;@ Undefined V behavior part II\n");\r
+//    ot("  orr r9,r9,r3,lsl #4 ;@ V\n");\r
     ot("  movs r0,r0,lsl #4\n");\r
-       ot("  orrmi r9,r9,#0x90000000 ;@ Undefined N+V behavior\n"); // this is what Musashi really does\r
-       ot("  bicne r9,r9,#0x40000000 ;@ Z flag\n");\r
+    ot("  orrmi r9,r9,#0x90000000 ;@ Undefined N+V behavior\n"); // this is what Musashi really does\r
+    ot("  bicne r9,r9,#0x40000000 ;@ Z flag\n");\r
   }\r
   else\r
   {\r
     ot("  ldrb r0,[r7,#0x45] ;@ Get X bit\n");\r
     ot("  mov r3,#0x00f00000\n");\r
     ot("  and r2,r3,r10,lsr #4\n");\r
-       ot("  tst r0,#2\n");\r
+    ot("  tst r0,#2\n");\r
     ot("  and r0,r3,r1,lsr #4\n");\r
     ot("  sub r0,r0,r2\n");\r
     ot("  subne r0,r0,#0x00100000\n");\r
@@ -425,13 +425,13 @@ int OpAbcd(int op)
     ot("  mov r2,r10,lsr #28\n");\r
     ot("  sub r0,r0,r2,lsl #24\n");\r
     ot("  cmp r0,#0x09900000\n");\r
-       ot("  orrhi r9,r9,#0xa0000000 ;@ N and C\n");\r
-       ot("  addhi r0,r0,#0x0a000000\n");\r
-//     ot("  and r3,r9,r0,lsr #3 ;@ Undefined V behavior part II\n");\r
-//     ot("  orr r9,r9,r3,lsl #4 ;@ V\n");\r
+    ot("  orrhi r9,r9,#0xa0000000 ;@ N and C\n");\r
+    ot("  addhi r0,r0,#0x0a000000\n");\r
+//    ot("  and r3,r9,r0,lsr #3 ;@ Undefined V behavior part II\n");\r
+//    ot("  orr r9,r9,r3,lsl #4 ;@ V\n");\r
     ot("  movs r0,r0,lsl #4\n");\r
-//     ot("  orrmi r9,r9,#0x80000000 ;@ Undefined N behavior\n");\r
-       ot("  bicne r9,r9,#0x40000000 ;@ Z flag\n");\r
+//    ot("  orrmi r9,r9,#0x80000000 ;@ Undefined N behavior\n");\r
+    ot("  bicne r9,r9,#0x40000000 ;@ Z flag\n");\r
   }\r
 \r
   ot("  mov r2,r9,lsr #28\n");\r
@@ -456,7 +456,7 @@ int OpNbcd(int op)
   use=OpBase(op);\r
   if(op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op); Cycles=6;\r
+  OpStart(op,ea); Cycles=6;\r
   if(ea >= 8)  Cycles+=2;\r
 \r
   EaCalc(10,0x3f, ea,0,1);\r
@@ -519,7 +519,7 @@ int OpAritha(int op)
   use&=~0x0e00; // Use same opcode for An\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op); Cycles=(size==2)?6:8;\r
+  OpStart(op,sea); Cycles=(size==2)?6:8;\r
   if(size==2&&(sea<0x10||sea==0x3c)) Cycles+=2;\r
   if(type==1) Cycles=6;\r
 \r
@@ -566,7 +566,7 @@ int OpAddx(int op)
   if (size==0&&(sea==0x27||dea==0x27)) use=op; // ___x.b -(a7)\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op);  Cycles=4;\r
+  OpStart(op,sea|dea); Cycles=4;\r
   if(size>=2)   Cycles+=4;\r
   if(sea>=0x10) Cycles+=2;\r
 \r
@@ -583,7 +583,7 @@ int OpAddx(int op)
   if (type==5 && size<2)\r
   {\r
     ot(";@ Make sure the carry bit will tip the balance:\n");\r
-       ot("  mvn r2,#0\n");\r
+    ot("  mvn r2,#0\n");\r
     ot("  orr r11,r11,r2,lsr #%i\n",(size==0)?8:16);\r
     ot("\n");\r
   }\r
@@ -631,7 +631,7 @@ int OpCmpEor(int op)
   use&=~0x0e00; // Use 1 handler for register d0-7\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op); Cycles=4;\r
+  OpStart(op,ea); Cycles=4;\r
   if(eor) {\r
     if(ea>8)     Cycles+=4;\r
     if(size>=2)  Cycles+=4;\r
@@ -678,7 +678,7 @@ int OpCmpm(int op)
   if (size==0&&(sea==0x1f||dea==0x1f)) use=op; // ..except (a7)+\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op); Cycles=4;\r
+  OpStart(op,sea); Cycles=4;\r
 \r
   ot(";@ Get src operand into r10:\n");\r
   EaCalc (0,0x000f, sea,size,1);\r
@@ -719,7 +719,7 @@ int OpChk(int op)
   use&=~0x0e00; // Use 1 handler for register d0-7\r
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
 \r
-  OpStart(op); Cycles=10;\r
+  OpStart(op,ea); Cycles=10;\r
 \r
   ot(";@ Get EA into r10 and value into r0:\n");\r
   EaCalc (10,0x003f,  ea,size,1);\r