Skip to content

fix inc_lr and dec_lr overflow#454

Open
remind-me-later wants to merge 2 commits intoLIJI32:masterfrom
remind-me-later:master
Open

fix inc_lr and dec_lr overflow#454
remind-me-later wants to merge 2 commits intoLIJI32:masterfrom
remind-me-later:master

Conversation

@remind-me-later
Copy link
Copy Markdown
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.

Comment thread Core/sm83_cpu.c
register_id = (opcode >> 4) + 1;

value = (gb->registers[register_id] & 0xFF) + 1;
value = (gb->registers[register_id] + 1) & 0xFF;
Copy link
Copy Markdown
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
@LIJI32 LIJI32 force-pushed the master branch 2 times, most recently from 4873d7c to 858f003 Compare December 29, 2025 11:56
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