X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2FCyclone%2FOpLogic.cpp;h=4bd0869569c4a281995c7c44af9a6f4e3e173cd3;hb=0e11c502b05a9ccd67d34d1f0975852d8c3d4232;hp=33be8c94ac605efabe984d244ca48b9fd6e88aa0;hpb=3a5e6cf8477084dd63ab1eeadef88db3d218caea;p=picodrive.git diff --git a/cpu/Cyclone/OpLogic.cpp b/cpu/Cyclone/OpLogic.cpp index 33be8c9..4bd0869 100644 --- a/cpu/Cyclone/OpLogic.cpp +++ b/cpu/Cyclone/OpLogic.cpp @@ -23,7 +23,7 @@ int OpBtstReg(int op) if (EaCanWrite(tea)==0) return 1; } - use=OpBase(op); + use=OpBase(op,size); use&=~0x0e00; // Use same handler for all registers if (op!=use) { OpUse(op,use); return 0; } // Use existing handler @@ -36,13 +36,9 @@ int OpBtstReg(int op) if(size>=2) Cycles+=2; } - EaCalc (10,0x0e00,sea,0,0,0); - EaRead (10, 10,sea,0,0x0e00,0,0); + EaCalcReadNoSE(-1,10,sea,0,0x0e00); - EaCalc ( 0,0x003f,tea,size,0,0); - if (type>0) - ot(" mov r11,r0\n"); - EaRead ( 0, 0,tea,size,0x003f,0,0); + EaCalcReadNoSE((type>0)?11:-1,0,tea,size,0x003f); if (tea>=0x10) ot(" and r10,r10,#7 ;@ mem - do mod 8\n"); // size always 0 @@ -89,14 +85,13 @@ int OpBtstImm(int op) if (EaCanWrite(tea)==0) return 1; } - use=OpBase(op); + use=OpBase(op,size); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op,sea,tea); ot("\n"); - EaCalc ( 0,0x0000,sea,0,0,0); - EaRead ( 0, 0,sea,0,0,0,0); + EaCalcReadNoSE(-1,0,sea,0,0); ot(" mov r10,#1\n"); ot(" bic r9,r9,#0x40000000 ;@ Blank Z flag\n"); if (tea>=0x10) @@ -112,8 +107,7 @@ int OpBtstImm(int op) if(size>=2) Cycles+=2; } - EaCalc (11,0x003f,tea,size,0,0); - EaRead (11, 0,tea,size,0x003f,0,0); + EaCalcReadNoSE((type>0)?11:-1,0,tea,size,0x003f); ot(" tst r0,r10 ;@ Do arithmetic\n"); ot(" orreq r9,r9,#0x40000000 ;@ Get Z flag\n"); ot("\n"); @@ -146,7 +140,7 @@ int OpNeg(int op) if (EaCanRead (ea,size)==0||EaAn(ea)) return 1; if (EaCanWrite(ea )==0) return 1; - use=OpBase(op); + use=OpBase(op,size); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op,ea); Cycles=size<2?4:6; @@ -162,7 +156,7 @@ int OpNeg(int op) EaCalc (10,0x003f,ea,size,0,0); - if (type!=1) EaRead (10,0,ea,size,0x003f,0,0); // Don't need to read for 'clr' (or do we, for dummy read?) + if (type!=1) EaRead (10,0,ea,size,0x003f,0,0); // Don't need to read for 'clr' (or do we, for a dummy read?) if (type==1) ot("\n"); if (type==0) @@ -213,6 +207,7 @@ int OpNeg(int op) ot("\n"); } + if (type==1) eawrite_check_addrerr=1; EaWrite(10, 1,ea,size,0x003f,0,0); OpEnd(ea); @@ -260,7 +255,7 @@ int OpTst(int op) // See if we can do this opcode: if (EaCanWrite(sea)==0||EaAn(sea)) return 1; - use=OpBase(op); + use=OpBase(op,size); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op,sea); Cycles=4; @@ -288,7 +283,7 @@ int OpExt(int op) size=(op>>6)&1; shift=32-(8<=2; + OpStart(op,ea,0,changed_cycles); Cycles=8; if (ea<8) Cycles=4; if (cc) @@ -365,10 +361,12 @@ int OpSet(int op) ot("\n"); + eawrite_check_addrerr=1; EaCalc (0,0x003f, ea,size,0,0); EaWrite(0, 1, ea,size,0x003f,0,0); - OpEnd(ea); + opend_op_changes_cycles=changed_cycles; + OpEnd(ea,0); return 0; } @@ -383,7 +381,7 @@ static int EmitAsr(int op,int type,int dir,int count,int size,int usereg) if (usereg) { ot(";@ Use Dn for count:\n"); - ot(" and r2,r8,#7<<9\n"); + ot(" and r2,r8,#0x0e00\n"); ot(" ldr r2,[r7,r2,lsr #7]\n"); ot(" and r2,r2,#63\n"); ot("\n"); @@ -409,29 +407,30 @@ static int EmitAsr(int op,int type,int dir,int count,int size,int usereg) ot("\n"); } - if (type==0 && dir) ot(" mov r3,r0 ;@ save old value for V flag calculation\n"); + if (type==0 && dir) ot(" adds r3,r0,#0 ;@ save old value for V flag calculation, also clear V\n"); ot(";@ Shift register:\n"); if (type==0) ot(" movs r0,r0,%s %s\n",dir?"asl":"asr",pct); if (type==1) ot(" movs r0,r0,%s %s\n",dir?"lsl":"lsr",pct); - if (dir==0 && size<2) - { - ot(";@ restore after right shift:\n"); - ot(" mov r0,r0,lsl #%d\n",32-(8<>9)&7; dir =(op>>8)&1; size =(op>>6)&3; @@ -608,13 +602,13 @@ int OpAsr(int op) // Use the same opcode for target registers: use=op&~0x0007; - // As long as count is not 8, use the same opcode for all shift counts:: + // As long as count is not 8, use the same opcode for all shift counts: if (usereg==0 && count!=8 && !(count==1&&type==2)) { use|=0x0e00; count=-1; } if (usereg) { use&=~0x0e00; count=-1; } // Use same opcode for all Dn if (op!=use) { OpUse(op,use); return 0; } // Use existing handler - OpStart(op); Cycles=size<2?6:8; + OpStart(op,ea,0,count<0); Cycles=size<2?6:8; EaCalc(10,0x0007, ea,size,1); EaRead(10, 0, ea,size,0x0007,1); @@ -623,7 +617,8 @@ int OpAsr(int op) EaWrite(10, 0, ea,size,0x0007,1); - OpEnd(); + opend_op_changes_cycles = (count<0); + OpEnd(ea,0); return 0; } @@ -642,7 +637,7 @@ int OpAsrEa(int op) if (EaCanRead(ea,0)==0) return 1; if (EaCanWrite(ea)==0) return 1; - use=OpBase(op); + use=OpBase(op,size); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op,ea); Cycles=6; // EmitAsr() will add 2 @@ -668,7 +663,7 @@ int OpTas(int op, int gen_special) // See if we can do this opcode: if (EaCanWrite(ea)==0 || EaAn(ea)) return 1; - use=OpBase(op); + use=OpBase(op,0); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler if (!gen_special) OpStart(op,ea);