\r
if (lsl>0) ot(" ldr%s r%d,[r7,r%d,lsl #%i]\n",Narm[nsarm],v,a,lsl);\r
else if (lsl<0) ot(" ldr%s r%d,[r7,r%d,lsr #%i]\n",Narm[nsarm],v,a,-lsl);\r
- else ot(" ldr%s r%d,[r7,r%d]\n",Sarm[nsarm],v,a);\r
+ else ot(" ldr%s r%d,[r7,r%d]\n",type==earwt_sign_extend?Sarm[nsarm]:Narm[nsarm],v,a);\r
\r
if (type == earwt_shifted_up && shift)\r
ot(" mov%s r%d,r%d,asl #%d\n",s,v,v,shift);\r
}\r
\r
ot(";@ EaWrite: r%d into register[r%d]:\n",v,a);\r
- if (shift) ot(" mov r%d,r%d,asr #%d\n",v,v,shift);\r
+ if (shift) ot(" mov r%d,r%d,lsr #%d\n",v,v,shift);\r
\r
if (lsl>0) ot(" str%s r%d,[r7,r%d,lsl #%i]\n",Narm[size&3],v,a,lsl);\r
else if (lsl<0) ot(" str%s r%d,[r7,r%d,lsr #%i]\n",Narm[size&3],v,a,-lsl);\r
\r
if (ea==0x3c) { ot("Error! Write EA=0x%x\n\n",ea); return 1; }\r
\r
- if (shift) ot(" mov r1,r%d,asr #%d\n",v,shift);\r
- else if (v!=1) ot(" mov r1,r%d\n",v);\r
+ if (shift)\r
+ {\r
+ ot(" mov r1,r%d,lsr #%d\n",v,shift);\r
+ }\r
+ else if (v != 1 || (size < 2 && type != earwt_zero_extend))\r
+ {\r
+ switch (size) {\r
+ case 0:\r
+ ot(" and r1,r%d,#0xff\n",v);\r
+ break;\r
+ case 1:\r
+ if (type != earwt_zero_extend)\r
+ {\r
+ ot(" mov r1,r%d,lsl #16\n",v);\r
+ ot(" mov r1,r1,lsr #16\n");\r
+ break;\r
+ }\r
+ // fallthrough\r
+ case 2:\r
+ default:\r
+ ot(" mov r1,r%d\n",v);\r
+ break;\r
+ }\r
+ }\r
\r
MemHandler(1,size,a,eawrite_check_addrerr); // Call write handler\r
\r
// Emit a Move opcode, 00xxdddd ddssssss\r
int OpMove(int op)\r
{\r
+ EaRWType eatype;\r
int sea=0,tea=0;\r
int size=0,use=0;\r
int movea=0;\r
\r
if (movea==0)\r
{\r
- EaCalcRead(-1,1,sea,size,0x003f,earwt_sign_extend,1);\r
- OpGetFlagsNZ(1);\r
+ if (sea < 0x10 && size < 2)\r
+ {\r
+ eatype = earwt_zero_extend;\r
+ EaCalcRead(-1,1,sea,size,0x003f,eatype);\r
+ ot(" movs r2,r1,lsl #%d\n",size?16:24);\r
+ OpGetFlagsNZ(2);\r
+ }\r
+ else\r
+ {\r
+ eatype = earwt_shifted_up;\r
+ EaCalcRead(-1,1,sea,size,0x003f,eatype,1);\r
+ OpGetFlagsNZ(1);\r
+ }\r
ot("\n");\r
}\r
else\r
{\r
- EaCalcRead(-1,1,sea,size,0x003f,earwt_sign_extend);\r
+ eatype = earwt_sign_extend;\r
+ EaCalcRead(-1,1,sea,size,0x003f,eatype);\r
size=2; // movea always expands to 32-bits\r
}\r
\r
else\r
#endif\r
{\r
- EaCalc (0,0x0e00,tea,size,earwt_msb_dont_care);\r
- EaWrite(0, 1,tea,size,0x0e00,earwt_msb_dont_care);\r
+ EaCalc (0,0x0e00,tea,size,eatype);\r
+ EaWrite(0, 1,tea,size,0x0e00,eatype);\r
}\r
\r
#if CYCLONE_FOR_GENESIS && !MEMHANDLERS_CHANGE_CYCLES\r