if (mem)\r
{\r
ot(";@ Get src/dest EA vals\n");\r
- EaCalc (0,0x000f, sea,0,earwt_shifted_up);\r
- EaRead (0, 6, sea,0,0x000f,earwt_shifted_up);\r
+ EaCalc (0,0x000f, sea,0,earwt_msb_dont_care);\r
+ EaRead (0, 6, sea,0,0x000f,earwt_msb_dont_care);\r
EaCalcRead(11,0,dea,0,0x0e00,earwt_msb_dont_care);\r
}\r
else\r
ot(";@ Get src/dest reg vals\n");\r
EaCalcRead(-1,6,sea,0,0x0007,earwt_msb_dont_care);\r
EaCalcRead(11,0,dea,0,0x0e00,earwt_msb_dont_care);\r
- ot(" mov r6,r6,asl #24\n");\r
}\r
- ot(" mov r1,r0,asl #24\n\n");\r
\r
ot(" bic r10,r10,#0xb1000000 ;@ clear all flags except old Z\n");\r
\r
+ ot(" ldr r1,[r7,#0x4c] ;@ Get X bit\n");\r
+ ot(" and r2,r0,#0x0f\n");\r
+ ot(" movs r12,r1,lsl #3 ;@ X into carry\n");\r
+ ot(" and r1,r6,#0x0f\n");\r
if (type)\r
{\r
- ot(" ldr r0,[r7,#0x4c] ;@ Get X bit\n");\r
- ot(" mov r3,#0x00f00000\n");\r
- ot(" and r2,r3,r1,lsr #4\n");\r
- ot(" tst r0,#0x20000000\n");\r
- ot(" and r0,r3,r6,lsr #4\n");\r
- ot(" add r0,r0,r2\n");\r
- ot(" addne r0,r0,#0x00100000\n");\r
-// ot(" tst r0,#0x00800000\n");\r
-// ot(" orreq r10,r10,#0x01000000 ;@ Undefined V behavior\n");\r
- ot(" cmp r0,#0x00900000\n");\r
- ot(" addhi r0,r0,#0x00600000 ;@ Decimal adjust units\n");\r
-\r
- ot(" mov r2,r1,lsr #28\n");\r
- ot(" add r0,r0,r2,lsl #24\n");\r
- ot(" mov r2,r6,lsr #28\n");\r
- ot(" add r0,r0,r2,lsl #24\n");\r
- ot(" cmp r0,#0x09900000\n");\r
+ // abcd\r
+ ot(" adc r1,r2,r1\n");\r
+ ot(" cmp r1,#9\n");\r
+\r
+ ot(" and r0,r0,#0xf0\n");\r
+ ot(" and r6,r6,#0xf0\n");\r
+ ot(" add r1,r1,r0\n");\r
+ ot(" add r1,r1,r6\n");\r
+ ot(" mov r12,r1\n");\r
+ ot(" addhi r12,#6 ;@ Decimal adjust units\n");\r
+ ot(" tst r1,#0x80\n");\r
+ ot(" orreq r10,r10,#0x10000000 ;@ Undefined V behavior\n");\r
+ ot(" cmp r12,#0x9f\n");\r
ot(" orrhi r10,r10,#0x20000000 ;@ C\n");\r
- ot(" subhi r0,r0,#0x0a000000\n");\r
-// ot(" and r3,r10,r0,lsr #3 ;@ Undefined V behavior part II\n");\r
-// ot(" orr r10,r10,r3,lsl #4 ;@ V\n");\r
- ot(" movs r0,r0,lsl #4\n");\r
- ot(" orrmi r10,r10,#0x90000000 ;@ Undefined N+V behavior\n"); // this is what Musashi really does\r
- ot(" bicne r10,r10,#0x40000000 ;@ Z flag\n");\r
+ ot(" subhi r12,r12,#0xa0\n");\r
+ ot(" movs r0,r12,lsl #24\n");\r
+ ot(" bicpl r10,r10,#0x10000000 ;@ Undefined V behavior part II\n");\r
}\r
else\r
{\r
- ot(" ldr r0,[r7,#0x4c] ;@ Get X bit\n");\r
- ot(" mov r3,#0x00f00000\n");\r
- ot(" and r2,r3,r6,lsr #4\n");\r
- ot(" tst r0,#0x20000000\n");\r
- ot(" and r0,r3,r1,lsr #4\n");\r
- ot(" sub r0,r0,r2\n");\r
- ot(" subne r0,r0,#0x00100000\n");\r
-// ot(" tst r0,#0x00800000\n");\r
-// ot(" orreq r10,r10,#0x01000000 ;@ Undefined V behavior\n");\r
- ot(" cmp r0,#0x00900000\n");\r
- ot(" subhi r0,r0,#0x00600000 ;@ Decimal adjust units\n");\r
-\r
- ot(" mov r2,r1,lsr #28\n");\r
- ot(" add r0,r0,r2,lsl #24\n");\r
- ot(" mov r2,r6,lsr #28\n");\r
- ot(" sub r0,r0,r2,lsl #24\n");\r
- ot(" cmp r0,#0x09900000\n");\r
- ot(" orrhi r10,r10,#0xa0000000 ;@ N and C\n");\r
- ot(" addhi r0,r0,#0x0a000000\n");\r
-// ot(" and r3,r10,r0,lsr #3 ;@ Undefined V behavior part II\n");\r
-// ot(" orr r10,r10,r3,lsl #4 ;@ V\n");\r
- ot(" movs r0,r0,lsl #4\n");\r
-// ot(" orrmi r10,r10,#0x80000000 ;@ Undefined N behavior\n");\r
- ot(" bicne r10,r10,#0x40000000 ;@ Z flag\n");\r
+ // sbcd\r
+ ot(" mov r12,#0 ;@ corf\n");\r
+ ot(" adc r1,r1,#0\n");\r
+ ot(" sub r1,r2,r1\n");\r
+ ot(" cmp r1,#0x0f\n");\r
+ ot(" movhi r12,#6\n");\r
+\r
+ ot(" and r0,r0,#0xf0\n");\r
+ ot(" and r6,r6,#0xf0\n");\r
+ ot(" add r1,r1,r0\n");\r
+ ot(" sub r1,r1,r6\n");\r
+ ot(" tst r1,#0x80\n");\r
+ ot(" orrne r10,r10,#0x10000000 ;@ Undefined V behavior\n");\r
+ ot(" cmp r1,r12\n");\r
+ ot(" orrlt r10,r10,#0x20000000 ;@ C\n");\r
+ ot(" cmp r1,#0xff\n");\r
+ ot(" addhi r1,#0xa0\n");\r
+ ot(" sub r12,r1,r12\n");\r
+ ot(" movs r0,r12,lsl #24\n");\r
+ ot(" bicmi r10,r10,#0x10000000 ;@ Undefined V behavior part II\n");\r
}\r
\r
+ ot(" orrmi r10,r10,#0x80000000 ;@ Undefined N behavior\n");\r
+ ot(" bicne r10,r10,#0x40000000 ;@ Z flag\n");\r
ot(" str r10,[r7,#0x4c] ;@ Save X bit\n");\r
ot("\n");\r
\r
OpStart(op,ea); Cycles=6;\r
if(ea >= 8) Cycles+=2;\r
\r
- EaCalcRead(6,0,ea,0,0x003f,earwt_msb_dont_care);\r
+ EaCalcRead(11,0,ea,0,0x003f,earwt_zero_extend);\r
\r
// this is rewrite of Musashi's code\r
ot(" ldr r2,[r7,#0x4c]\n");\r
ot(" bic r10,r10,#0xb0000000 ;@ clear all flags, except Z\n");\r
- ot(" mov r0,r0,asl #24\n");\r
ot(" and r2,r2,#0x20000000\n");\r
- ot(" add r2,r0,r2,lsr #5 ;@ add X\n");\r
- ot(" rsb r11,r2,#0x9a000000 ;@ do arithmetic\n");\r
+ ot(" rsb r1,r0,#0 ;@ do arithmetic\n");\r
+ ot(" subs r1,r1,r2,lsr #29 ;@ X\n");\r
\r
- ot(" cmp r11,#0x9a000000\n");\r
ot(" beq finish%.4x\n",op);\r
ot("\n");\r
\r
- ot(" mvn r3,r11,lsr #31 ;@ Undefined V behavior\n");\r
- ot(" and r2,r11,#0x0f000000\n");\r
- ot(" cmp r2,#0x0a000000\n");\r
- ot(" andeq r11,r11,#0xf0000000\n");\r
- ot(" addeq r11,r11,#0x10000000\n");\r
- ot(" and r3,r3,r11,lsr #31 ;@ Undefined V behavior part II\n");\r
- ot(" movs r1,r11,asr #24\n");\r
+ ot(" movs r1,r1,lsl #24\n");\r
+ ot(" orrmi r10,r10,#0x10000000 ;@ Undefined V behavior\n");\r
+ ot(" orr r2,r1,r0,lsl #24\n");\r
+ ot(" tst r2,#0x0f000000\n");\r
+ ot(" andeq r1,r1,#0xf0000000\n");\r
+ ot(" orreq r1,r1,#0x06000000\n");\r
+ ot(" adds r1,r1,#0x9a000000\n");\r
+ ot(" bicmi r10,r10,#0x10000000 ;@ Undefined V behavior part II\n");\r
+ ot(" orrmi r10,r10,#0x80000000 ;@ Undefined N behavior\n");\r
ot(" bicne r10,r10,#0x40000000 ;@ Z\n");\r
- ot(" orr r10,r10,r3,lsl #28 ;@ save V\n");\r
ot(" orr r10,r10,#0x20000000 ;@ C\n");\r
ot("\n");\r
\r
- EaWrite(6, 1, ea,0,0x3f,earwt_msb_dont_care);\r
+ EaWrite(11, 1, ea,0,0x3f,earwt_shifted_up);\r
\r
ot("finish%.4x%s\n",op,ms?"":":");\r
- ot(" tst r11,r11\n");\r
- ot(" orrmi r10,r10,#0x80000000 ;@ N\n");\r
ot(" str r10,[r7,#0x4c] ;@ Save X\n");\r
ot("\n");\r
\r
return 0;\r
}\r
\r
+// vim:ts=2:sw=2:expandtab\r