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,13 +71,22 @@ 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("LSL.b");
// test.executeBinTest("ASL.w"); test.executeBinTest("LSL.w");
// test.executeBinTest("ASL.l"); 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");
}
public void testBcc() { public void testBcc() {
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");