X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=OpBranch.cpp;h=9a7c8da37aa32233468471e063348a8cce6017ab;hb=ee2d42257a2d52072f6b163f8ec279503241e9de;hp=c37620ad7b975547f406a86ca2c20e528be77596;hpb=52ac6b1c8f65fe2477ffc3a7fc63ca8ae9d7e59f;p=cyclone68000.git diff --git a/OpBranch.cpp b/OpBranch.cpp index c37620a..9a7c8da 100644 --- a/OpBranch.cpp +++ b/OpBranch.cpp @@ -113,8 +113,8 @@ int OpLink(int op) if(reg!=7) { ot(";@ Get An\n"); - EaCalc(11, 7, 8, 2, 1); - EaRead(11, 1, 8, 2, 7, 1); + EaCalc(11, 7, 8, 2); + EaRead(11, 1, 8, 2, 7); } ot(" ldr r0,[r7,#0x3c] ;@ Get A7\n"); @@ -128,7 +128,7 @@ int OpLink(int op) ot(";@ Save to An\n"); if(reg!=7) - EaWrite(11,8, 8, 2, 7, 1); + EaWrite(11, 8, 8, 2, 7); ot(";@ Get offset:\n"); EaCalc(0,0,0x3c,1); // abused r8 is ok because of imm EA @@ -154,8 +154,8 @@ int OpUnlk(int op) OpStart(op,0x10); ot(";@ Get An\n"); - EaCalc(11, 0xf, 8, 2, 1); - EaRead(11, 0, 8, 2, 0xf, 1); + EaCalc(11, 0xf, 8, 2); + EaRead(11, 0, 8, 2, 0xf); ot(" add r8,r0,#4 ;@ A7+=4, abuse r8\n"); ot("\n"); @@ -165,7 +165,7 @@ int OpUnlk(int op) ot(" str r8,[r7,#0x3c] ;@ Save A7\n"); ot("\n"); ot(";@ An = value from stack:\n"); - EaWrite(11, 0, 8, 2, 7, 1); + EaWrite(11, 0, 8, 2, 7); Cycles=12; OpEnd(0x10); @@ -312,6 +312,7 @@ static const char * const Cond[16]= // Emit a Dbra opcode, 0101cccc 11001nnn vv int OpDbra(int op) { + const char *cond; int use=0; int cc=0; @@ -321,25 +322,12 @@ int OpDbra(int op) if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op); - switch (cc) + if (cc>=2) { - case 0: // T - case 1: // F - break; - case 2: // hi - ot(" tst r10,#0x60000000 ;@ hi: !C && !Z\n"); - ot(" beq DbraTrue\n\n"); - break; - case 3: // ls - ot(" tst r10,#0x60000000 ;@ ls: C || Z\n"); - ot(" bne DbraTrue\n\n"); - break; - default: - ot(";@ Is the condition true?\n"); - ot(" msr cpsr_flg,r10 ;@ ARM flags = 68000 flags\n"); - ot(";@ If so, don't dbra\n"); - ot(" b%s DbraTrue\n\n",Cond[cc]); - break; + ot(";@ Is the condition true?\n"); + cond=TestCond(cc); + ot(";@ If so, don't dbra\n"); + ot(" b%s DbraTrue\n\n",cond); } if (cc!=0) @@ -348,6 +336,7 @@ int OpDbra(int op) ot(" and r1,r8,#0x0007\n"); ot(" mov r1,r1,lsl #2\n"); ot(" ldrsh r0,[r7,r1]\n"); + ot(" strb r8,[r7,#0x45] ;@ not polling\n"); ot(" sub r0,r0,#1\n"); ot(" strh r0,[r7,r1]\n"); ot("\n"); @@ -418,6 +407,8 @@ int OpBranch(int op) int offset=0; int cc=0; const char *asr_r11=""; + const char *cond; + int pc_reg=0; offset=(char)(op&0xff); cc=(op>>8)&15; @@ -428,30 +419,16 @@ int OpBranch(int op) if (size==2) size=0; // 000 model does not support long displacement if (size) use=op; // 16-bit or 32-bit - else use=(op&0xff00)+1; // Use same opcode for all 8-bit branches + else use=(op&0xff01)+2; // Use same opcode for all 8-bit branches if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op,size?0x10:0); Cycles=10; // Assume branch taken - switch (cc) + if (cc>=2) { - case 0: // T - case 1: // F - break; - case 2: // hi - ot(" tst r10,#0x60000000 ;@ hi: !C && !Z\n"); - ot(" bne BccDontBranch%i\n\n",8<=2&&(op&0xff00)==0x6700) + if (cc>=2&&(op&0xff01)==0x6700) { ot("BccDontBranch%i%s\n", 8<