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

SBC (subtract with carry) #51

Open
meCodeUp opened this issue May 6, 2022 · 1 comment
Open

SBC (subtract with carry) #51

meCodeUp opened this issue May 6, 2022 · 1 comment

Comments

@meCodeUp
Copy link

meCodeUp commented May 6, 2022

It seems that SBC is not calculating correctly

Address  Hexdump   Dissassembly
-------------------------------
$0600    a9 09     LDA #$09
$0602    e9 01     SBC #$01

0600: a9 09 e9 01

A=$07 X=$00 Y=$00
SP=$ff PC=$0605
NV-BDIZC
00110001
@chipster6502
Copy link

The calculation is correct.

SBC is subtract with carry. If C is 0 prior to the SBC instruction, it subtracts one more than you expect.

To avoid the problem, always use SEC instruction before SBC

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

No branches or pull requests

2 participants