Skip to content

Fix SBC carry flag calculation#1

Open
garry-jeromson wants to merge 1 commit intoElectronicsTinkerer:mainfrom
garry-jeromson:main
Open

Fix SBC carry flag calculation#1
garry-jeromson wants to merge 1 commit intoElectronicsTinkerer:mainfrom
garry-jeromson:main

Conversation

@garry-jeromson
Copy link
Copy Markdown

The carry flag was being calculated using the modified accumulator value instead of the original value. For SBC, carry should be set if no borrow occurred (A >= M + (1 - C_in)), which requires using the original A and carry values before the subtraction.

Save original A and C at the start of the function and use them for the carry calculation. This fixes unsigned comparisons that rely on the carry flag after SBC.

The carry flag was being calculated using the modified accumulator value
instead of the original value. For SBC, carry should be set if no borrow
occurred (A >= M + (1 - C_in)), which requires using the original A and
carry values before the subtraction.

Save original A and C at the start of the function and use them for the
carry calculation. This fixes unsigned comparisons that rely on the carry
flag after SBC.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant