Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag Optimizations #222

Merged
merged 7 commits into from
Oct 30, 2020
Merged

Flag Optimizations #222

merged 7 commits into from
Oct 30, 2020

Conversation

enusbaum
Copy link
Member

  • Small Optimization/Refactor for CPU Flags
  • Removed them from a dedicated class & moved flag evaluation routines into CPU Core

Nets about a 5% speed bump in the benchmark on my local machine.

MBBSEmu/CPU/CPUCore.cs Outdated Show resolved Hide resolved
MBBSEmu/CPU/CPUCore.cs Show resolved Hide resolved
{
Registers.F = Registers.F.ClearFlag((ushort)EnumFlags.ZF);
}
Registers.F = result.IsNegative() ? Registers.F.SetFlag((ushort)EnumFlags.SF) : Registers.F.ClearFlag((ushort)EnumFlags.SF);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if result.IsNegative() you can skip evaluation of Zero since it's obviously not 0

e.g.

if (result.IsNegative()) {
  setFlag(SF);
  clearFlag(ZF);
} else {
  clearFlag(SF);
  if (result == 0) .... set | clear
}

@paladine paladine merged commit 4a2c663 into master Oct 30, 2020
@enusbaum enusbaum deleted the flag-optimizations branch October 31, 2020 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants