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

fix inc_lr and dec_lr overflow #454

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

remind-me-later
Copy link
Contributor

I think the old version could overflow changing the value of the high register, but worked fine. I'm sorry if this is another instance of C doing some implicit casting I'm not seeing.

@@ -595,7 +595,7 @@ static void inc_lr(GB_gameboy_t *gb, uint8_t opcode)
uint8_t value;
register_id = (opcode >> 4) + 1;

value = (gb->registers[register_id] & 0xFF) + 1;
value = (gb->registers[register_id] + 1) & 0xFF;
Copy link
Contributor

@jkotlinski jkotlinski Aug 6, 2022

Choose a reason for hiding this comment

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

The & 0xff part is redundant, as the value is implicitly casted to uint8_t.

@LIJI32 LIJI32 force-pushed the master branch 4 times, most recently from 4ebe973 to 0989ee2 Compare December 30, 2022 17:45
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.

None yet

2 participants