Skip to content

Commit

Permalink
shift fix / setmo+setmoc
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Sep 2, 2023
1 parent e5ac3a9 commit abfd55e
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions XT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3573,10 +3573,6 @@ public bool Tick()
//bool count_1_of = opcode is (0xd0 or 0xd1);
bool count_1_of = count == 1;

count &= 31; // masked to 5 bits
// only since 286?
// count %= (word ? 17 : 9); // from documentation ( https://www.felixcloutier.com/x86/rcl:rcr:rol:ror )

bool oldSign = (word ? v1 & 0x8000 : v1 & 0x80) != 0;

bool set_flags = false;
Expand Down Expand Up @@ -3745,6 +3741,42 @@ public bool Tick()
Log.DoLog($"{prefixStr} SHR {vName},{countName}");
#endif
}
else if (mode == 6)
{
if (opcode >= 0xd2)
{
if (_cl != 0)
{
SetFlagC(false);
SetFlagA(false);
SetFlagZ(false);
SetFlagO(false);
SetFlagP(0xff);
SetFlagS(true);

v1 = (ushort)(word ? 0xffff : 0xff);
}

#if DEBUG
Log.DoLog($"{prefixStr} SETMOC");
#endif
}
else
{
SetFlagC(false);
SetFlagA(false);
SetFlagZ(false);
SetFlagO(false);
SetFlagP(0xff);
SetFlagS(true);

v1 = (ushort)(word ? 0xffff : 0xff);

#if DEBUG
Log.DoLog($"{prefixStr} SETMO");
#endif
}
}
else if (mode == 7)
{
// SAR
Expand Down

0 comments on commit abfd55e

Please sign in to comment.