Fixed LSL/LSR/ROL/ROR

This commit is contained in:
Rodolphe de Saint Léger 2025-05-19 12:16:18 +02:00
parent 4aad8cbc96
commit d2d7171a18
14 changed files with 70 additions and 57 deletions

View file

@ -1349,6 +1349,8 @@ public class CoreALU {
sr ^= (sr ^ (cx | z | n)) & (FL_C | FL_V | FL_Z | FL_N | FL_X); sr ^= (sr ^ (cx | z | n)) & (FL_C | FL_V | FL_Z | FL_N | FL_X);
} else { } else {
res = (byte) res;
int n = (res >> 28) & FL_N; int n = (res >> 28) & FL_N;
int z = (~((res | -res) >> 31)) & FL_Z; int z = (~((res | -res) >> 31)) & FL_Z;
@ -1380,6 +1382,8 @@ public class CoreALU {
sr ^= (sr ^ (cx | z | n)) & (FL_C | FL_V | FL_Z | FL_N | FL_X); sr ^= (sr ^ (cx | z | n)) & (FL_C | FL_V | FL_Z | FL_N | FL_X);
} else { } else {
res = (short) res;
int n = (res >> 28) & FL_N; int n = (res >> 28) & FL_N;
int z = (~((res | -res) >> 31)) & FL_Z; int z = (~((res | -res) >> 31)) & FL_Z;
@ -1613,7 +1617,7 @@ public class CoreALU {
shift &= 0x3f; shift &= 0x3f;
if (shift > 0) { if (shift > 0) {
shift &= 7; shift &= 15;
short res = (short) ((dst << (16 - shift)) | ((dst & 0xffff) >>> shift)); short res = (short) ((dst << (16 - shift)) | ((dst & 0xffff) >>> shift));
int cn = (res >> 31) & (FL_N | FL_C); int cn = (res >> 31) & (FL_N | FL_C);
@ -1637,7 +1641,7 @@ public class CoreALU {
shift &= 0x3f; shift &= 0x3f;
if (shift > 0) { if (shift > 0) {
shift &= 7; shift &= 31;
int res = (dst << (32 - shift)) | (dst >>> shift); int res = (dst << (32 - shift)) | (dst >>> shift);
int cn = (res >> 31) & (FL_N | FL_C); int cn = (res >> 31) & (FL_N | FL_C);

View file

@ -71,51 +71,60 @@ public class InstructionTests extends TestCase {
test.executeBinTest("BTST"); test.executeBinTest("BTST");
} }
// public void testASL() { public void testShift() {
// CoreTest test = new CoreTest(0xffffff + 1, true); CoreTest test = new CoreTest(0xffffff + 1, true);
//
// test.executeBinTest("ASL.b");
// test.executeBinTest("ASL.w");
// test.executeBinTest("ASL.l");
// }
public void testBcc() { test.executeBinTest("LSL.b");
CoreTest test = new CoreTest(0xffffff + 1, true); test.executeBinTest("LSL.w");
test.executeBinTest("LSL.l");
test.executeBinTest("LSR.b");
test.executeBinTest("LSR.w");
test.executeBinTest("LSR.l");
test.executeBinTest("ROL.b");
test.executeBinTest("ROL.w");
test.executeBinTest("ROL.l");
test.executeBinTest("ROR.b");
test.executeBinTest("ROR.w");
test.executeBinTest("ROR.l");
}
test.executeBinTest("Bcc", 373, 466, 570, 1547, 1695, 1782, 2166, 2224, 2441); public void testBcc() {
test.executeBinTest("BSR", 25, 573, 814, 1357, 1443, 1509, 1734, 1934, 2232, 2338); CoreTest test = new CoreTest(0xffffff + 1, true);
}
public void testDBcc() { test.executeBinTest("Bcc", 373, 466, 570, 1547, 1695, 1782, 2166, 2224, 2441);
CoreTest test = new CoreTest(0xffffff + 1, true); test.executeBinTest("BSR", 25, 573, 814, 1357, 1443, 1509, 1734, 1934, 2232, 2338);
}
test.executeBinTest("DBcc"); public void testDBcc() {
} CoreTest test = new CoreTest(0xffffff + 1, true);
public void testMisc() { test.executeBinTest("DBcc");
CoreTest test = new CoreTest(0xffffff + 1, true); }
test.executeBinTest("NOP"); public void testMisc() {
test.executeBinTest("EXG"); CoreTest test = new CoreTest(0xffffff + 1, true);
test.executeBinTest("SWAP");
test.executeBinTest("EXT.w"); test.executeBinTest("NOP");
test.executeBinTest("EXT.l"); test.executeBinTest("EXG");
test.executeBinTest("LEA"); test.executeBinTest("SWAP");
test.executeBinTest("PEA"); test.executeBinTest("EXT.w");
test.executeBinTest("RTS"); test.executeBinTest("EXT.l");
test.executeBinTest("RTR"); test.executeBinTest("LEA");
test.executeBinTest("LINK"); test.executeBinTest("PEA");
test.executeBinTest("UNLINK"); test.executeBinTest("RTS");
test.executeBinTest("Scc"); test.executeBinTest("RTR");
test.executeBinTest("TST.b"); test.executeBinTest("LINK");
test.executeBinTest("TST.w"); test.executeBinTest("UNLINK");
test.executeBinTest("TST.l"); test.executeBinTest("Scc");
test.executeBinTest("CLR.b"); test.executeBinTest("TST.b");
test.executeBinTest("CLR.w"); test.executeBinTest("TST.w");
test.executeBinTest("CLR.l"); test.executeBinTest("TST.l");
test.executeBinTest("TRAP"); test.executeBinTest("CLR.b");
test.executeBinTest("TRAPV"); test.executeBinTest("CLR.w");
} test.executeBinTest("CLR.l");
test.executeBinTest("TRAP");
test.executeBinTest("TRAPV");
}
public void testJMP() { public void testJMP() {
CoreTest test = new CoreTest(0xffffff + 1, true); CoreTest test = new CoreTest(0xffffff + 1, true);
@ -153,22 +162,22 @@ public class InstructionTests extends TestCase {
test.executeBinTest("MOVE.b"); test.executeBinTest("MOVE.b");
/* /*
* 295 is not compatible (post incremented value is written by design) * 295 is not compatible (post incremented value is written by design) 342 is
* 342 is not compatible (post incremented value is written by design) * not compatible (post incremented value is written by design) 494 is not
* 494 is not compatible (post incremented value is written by design) * compatible (post incremented value is written by design) 994 is not
* 994 is not compatible (pre decremented value is written by design) * compatible (pre decremented value is written by design) 1225 is not
* 1225 is not compatible (pre decremented value is written by design) * compatible (pre decremented value is written by design) 1846 is not
* 1846 is not compatible (post incremented value is written by design) * compatible (post incremented value is written by design)
*/ */
test.executeBinTest("MOVE.w", 295, 342, 494, 994, 1225, 1846); test.executeBinTest("MOVE.w", 295, 342, 494, 994, 1225, 1846);
/* /*
* 217 is not compatible (post incremented value is written by design) * 217 is not compatible (post incremented value is written by design) 502 is
* 502 is not compatible (post incremented value is written by design) * not compatible (post incremented value is written by design) 1152 is not
* 1152 is not compatible (post incremented value is written by design) * compatible (post incremented value is written by design) 1691 is not
* 1691 is not compatible (post incremented value is written by design) * compatible (post incremented value is written by design) 1830 is not
* 1830 is not compatible (pre decremented value is written by design) * compatible (pre decremented value is written by design) 2057 is not
* 2057 is not compatible (post incremented value is written by design) * compatible (post incremented value is written by design) 2135 is not
* 2135 is not compatible (post incremented value is written by design) * compatible (post incremented value is written by design)
*/ */
test.executeBinTest("MOVE.l", 217, 502, 1152, 1691, 1830, 2057, 2135); test.executeBinTest("MOVE.l", 217, 502, 1152, 1691, 1830, 2057, 2135);
test.executeBinTest("MOVE.q"); test.executeBinTest("MOVE.q");