fix compatibility with ancient gas
[cyclone68000.git] / OpBranch.cpp
index fb4f561..9a7c8da 100644 (file)
@@ -113,8 +113,8 @@ int OpLink(int op)
 \r
   if(reg!=7) {\r
     ot(";@ Get An\n");\r
-    EaCalc(11, 7, 8, 2, 1);\r
-    EaRead(11, 1, 8, 2, 7, 1);\r
+    EaCalc(11, 7, 8, 2);\r
+    EaRead(11, 1, 8, 2, 7);\r
   }\r
 \r
   ot("  ldr r0,[r7,#0x3c] ;@ Get A7\n");\r
@@ -128,7 +128,7 @@ int OpLink(int op)
 \r
   ot(";@ Save to An\n");\r
   if(reg!=7)\r
-    EaWrite(11,8, 8, 2, 7, 1);\r
+    EaWrite(11, 8, 8, 2, 7);\r
 \r
   ot(";@ Get offset:\n");\r
   EaCalc(0,0,0x3c,1);    // abused r8 is ok because of imm EA\r
@@ -154,8 +154,8 @@ int OpUnlk(int op)
   OpStart(op,0x10);\r
 \r
   ot(";@ Get An\n");\r
-  EaCalc(11, 0xf, 8, 2,   1);\r
-  EaRead(11,   0, 8, 2, 0xf, 1);\r
+  EaCalc(11, 0xf, 8, 2);\r
+  EaRead(11,   0, 8, 2, 0xf);\r
 \r
   ot("  add r8,r0,#4 ;@ A7+=4, abuse r8\n");\r
   ot("\n");\r
@@ -165,7 +165,7 @@ int OpUnlk(int op)
   ot("  str r8,[r7,#0x3c] ;@ Save A7\n");\r
   ot("\n");\r
   ot(";@ An = value from stack:\n");\r
-  EaWrite(11, 0, 8, 2, 7, 1);\r
+  EaWrite(11, 0, 8, 2, 7);\r
 \r
   Cycles=12;\r
   OpEnd(0x10);\r
@@ -312,6 +312,7 @@ static const char * const Cond[16]=
 // Emit a Dbra opcode, 0101cccc 11001nnn vv\r
 int OpDbra(int op)\r
 {\r
+  const char *cond;\r
   int use=0;\r
   int cc=0;\r
 \r
@@ -321,25 +322,12 @@ int OpDbra(int op)
   if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
   OpStart(op);\r
 \r
-  switch (cc)\r
+  if (cc>=2)\r
   {\r
-    case 0: // T\r
-    case 1: // F\r
-      break;\r
-    case 2: // hi\r
-      ot("  tst r10,#0x60000000 ;@ hi: !C && !Z\n");\r
-      ot("  beq DbraTrue\n\n");\r
-      break;\r
-    case 3: // ls\r
-      ot("  tst r10,#0x60000000 ;@ ls: C || Z\n");\r
-      ot("  bne DbraTrue\n\n");\r
-      break;\r
-    default:\r
-      ot(";@ Is the condition true?\n");\r
-      ot("  msr cpsr_flg,r10 ;@ ARM flags = 68000 flags\n");\r
-      ot(";@ If so, don't dbra\n");\r
-      ot("  b%s DbraTrue\n\n",Cond[cc]);\r
-      break;\r
+    ot(";@ Is the condition true?\n");\r
+    cond=TestCond(cc);\r
+    ot(";@ If so, don't dbra\n");\r
+    ot("  b%s DbraTrue\n\n",cond);\r
   }\r
 \r
   if (cc!=0)\r
@@ -419,6 +407,7 @@ int OpBranch(int op)
   int offset=0;\r
   int cc=0;\r
   const char *asr_r11="";\r
+  const char *cond;\r
   int pc_reg=0;\r
 \r
   offset=(char)(op&0xff);\r
@@ -436,24 +425,10 @@ int OpBranch(int op)
   OpStart(op,size?0x10:0);\r
   Cycles=10; // Assume branch taken\r
 \r
-  switch (cc)\r
+  if (cc>=2)\r
   {\r
-    case 0: // T\r
-    case 1: // F\r
-      break;\r
-    case 2: // hi\r
-      ot("  tst r10,#0x60000000 ;@ hi: !C && !Z\n");\r
-      ot("  bne BccDontBranch%i\n\n",8<<size);\r
-      break;\r
-    case 3: // ls\r
-      ot("  tst r10,#0x60000000 ;@ ls: C || Z\n");\r
-      ot("  beq BccDontBranch%i\n\n",8<<size);\r
-      break;\r
-    default:\r
-      ot(";@ Is the condition true?\n");\r
-      ot("  msr cpsr_flg,r10 ;@ ARM flags = 68000 flags\n");\r
-      ot("  b%s BccDontBranch%i\n\n",Cond[cc^1],8<<size);\r
-      break;\r
+    cond=TestCond(cc,1);\r
+    ot("  b%s BccDontBranch%i\n\n",cond,8<<size);\r
   }\r
 \r
   if (size) \r