int type=0,size=0;\r
int sea=0,tea=0;\r
int use=0;\r
+ char *shiftstr="";\r
\r
// Get source and target EA\r
type=(op>>9)&7; if (type==4 || type>=7) return 1;\r
use=OpBase(op);\r
if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
\r
- OpStart(op, sea|tea); 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
-\r
EaCalc(11,0x003f, tea,size,1);\r
+ EaRead(10, 10, sea,size,0,0,0);\r
EaRead(11, 0, tea,size,0x003f,1);\r
\r
+ if (size==0) shiftstr=",asl #24";\r
+ else if (size==1) shiftstr=",asl #16";\r
+\r
ot(";@ Do arithmetic:\n");\r
\r
- if (type==0) ot(" orr r1,r0,r10\n");\r
- if (type==1) ot(" and r1,r0,r10\n");\r
- if (type==2) ot(" subs r1,r0,r10 ;@ Defines NZCV\n");\r
- if (type==3) ot(" adds r1,r0,r10 ;@ Defines NZCV\n");\r
- if (type==5) ot(" eor r1,r0,r10\n");\r
- if (type==6) ot(" cmp r0,r10 ;@ Defines NZCV\n");\r
+ if (type==0) ot(" orr r1,r0,r10%s\n",shiftstr);\r
+ if (type==1) ot(" and r1,r0,r10%s\n",shiftstr);\r
+ if (type==2) ot(" subs r1,r0,r10%s ;@ Defines NZCV\n",shiftstr);\r
+ if (type==3) ot(" adds r1,r0,r10%s ;@ Defines NZCV\n",shiftstr);\r
+ if (type==5) ot(" eor r1,r0,r10%s\n",shiftstr);\r
+ if (type==6) ot(" cmp r0,r10%s ;@ Defines NZCV\n",shiftstr);\r
\r
if (type<2 || type==5) ot(" adds r1,r1,#0 ;@ Defines NZ, clears CV\n"); // 0,1,5\r
\r
if (type==1 && size>=2 && tea<8) Cycles-=2;\r
}\r
\r
- OpEnd();\r
+ OpEnd(sea,tea);\r
\r
return 0;\r
}\r
{\r
int lsr=9-shift;\r
\r
- if (lsr>=0) ot(" mov r2,r8,lsr #%d ;@ Get quick value\n", lsr);\r
- else ot(" mov r2,r8,lsl #%d ;@ Get quick value\n",-lsr);\r
+ ot(" and r2,r8,#0x0e00 ;@ Get quick value\n");\r
+\r
+ if (lsr>=0) sprintf(count,"r2,lsr #%d", lsr);\r
+ else sprintf(count,"r2,lsl #%d", -lsr);\r
\r
- ot(" and r2,r2,#0x%.4x\n",7<<shift);\r
ot("\n");\r
- strcpy(count,"r2");\r
}\r
-\r
- if (num==8) sprintf(count,"#0x%.4x",8<<shift);\r
+ else\r
+ {\r
+ sprintf(count,"#0x%.4x",8<<shift);\r
+ }\r
\r
if (type==0) ot(" adds r1,r0,%s\n",count);\r
if (type==1) ot(" subs r1,r0,%s\n",count);\r
\r
EaWrite(10, 1, ea,size,0x003f,1);\r
\r
- OpEnd();\r
+ OpEnd(ea);\r
\r
return 0;\r
}\r
}\r
}\r
\r
- OpEnd();\r
+ OpEnd(ea);\r
\r
return 0;\r
}\r
EaWrite(0, 1,rea, 2,0x0e00,1);\r
\r
ot("endofop%.4x%s\n",op,ms?"":":");\r
- OpEnd();\r
+ OpEnd(ea);\r
\r
ot("divzero%.4x%s\n",op,ms?"":":");\r
ot(" mov r0,#0x14 ;@ Divide by zero\n");\r
ot(" bl Exception\n");\r
Cycles+=38;\r
- OpEnd();\r
+ OpEnd(ea);\r
ot("\n");\r
\r
return 0;\r
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,sea|dea); 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
ot(" strb r2,[r7,#0x45] ;@ Save X bit\n");\r
\r
EaWrite(11, 0, dea,0,0x0e00,1);\r
- OpEnd();\r
+ OpEnd(sea,dea);\r
\r
return 0;\r
}\r
ot(" mov r2,r9,lsr #28\n");\r
ot(" strb r2, [r7,#0x45]\n");\r
\r
- OpEnd();\r
+ OpEnd(ea);\r
\r
return 0;\r
}\r
if(type==1) Cycles=6;\r
\r
\r
- EaCalc ( 0,0x003f, sea,size);\r
- EaRead ( 0, 10, sea,size,0x003f);\r
+ // must calculate reg EA first, because of situations like: suba.w (A0)+, A0\r
+ EaCalc (10,0x0e00, dea,2,1);\r
+ EaRead (10, 11, dea,2,0x0e00);\r
\r
- EaCalc ( 0,0x0e00, dea,2,1);\r
- EaRead ( 0, 1, dea,2,0x0e00);\r
+ EaCalc ( 0,0x003f, sea,size);\r
+ EaRead ( 0, 0, sea,size,0x003f);\r
\r
- if (type==0) ot(" sub r1,r1,r10\n");\r
- if (type==1) ot(" cmp r1,r10 ;@ Defines NZCV\n");\r
+ if (type==0) ot(" sub r11,r11,r0\n");\r
+ if (type==1) ot(" cmp r11,r0 ;@ Defines NZCV\n");\r
if (type==1) OpGetFlags(1,0); // Get Cmp flags\r
- if (type==2) ot(" add r1,r1,r10\n");\r
+ if (type==2) ot(" add r11,r11,r0\n");\r
ot("\n");\r
\r
- if (type!=1) EaWrite( 0, 1, dea,2,0x0e00,1);\r
+ if (type!=1) EaWrite(10, 11, dea,2,0x0e00,1);\r
\r
- OpEnd();\r
+ OpEnd(sea);\r
\r
return 0;\r
}\r
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,sea|dea); Cycles=4;\r
+ OpStart(op,sea,dea); Cycles=4;\r
if(size>=2) Cycles+=4;\r
if(sea>=0x10) Cycles+=2;\r
\r
ot(";@ Save result:\n");\r
EaWrite( 0, 1, dea,size,0x0e00,1);\r
\r
- OpEnd();\r
+ OpEnd(sea,dea);\r
\r
return 0;\r
}\r
\r
if (eor) EaWrite(10, 1,ea,size,0x003f,1);\r
\r
- OpEnd();\r
+ OpEnd(ea);\r
return 0;\r
}\r
\r
ot(" cmp r0,r10\n");\r
OpGetFlags(1,0); // Cmp like subtract\r
\r
- OpEnd();\r
+ OpEnd(sea);\r
return 0;\r
}\r
\r
ot(";@ old N remains\n");\r
ot(" bic r9,r9,#0x80000000 ;@ N\n");\r
ot(" orr r9,r9,r3\n");\r
- OpEnd();\r
+ OpEnd(ea);\r
\r
ot("chktrap%.4x%s ;@ CHK exception:\n",op,ms?"":":");\r
ot(" mov r0,#0x18\n");\r
ot(" bl Exception\n");\r
Cycles+=40;\r
- OpEnd();\r
+ OpEnd(ea);\r
\r
return 0;\r
}\r