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

Explain the DAA instruction algorithm #1564

Merged
merged 2 commits into from
Nov 29, 2024
Merged

Explain the DAA instruction algorithm #1564

merged 2 commits into from
Nov 29, 2024

Conversation

Rangi42
Copy link
Contributor

@Rangi42 Rangi42 commented Nov 28, 2024

Fixes #1562

Refer to bloglien and SameBoy for DAA explanations. (I followed SameBoy's algorithm here; it's more verbose but also more obvious in the add/subtract distinction.)

image

@Rangi42 Rangi42 added docs This affects the documentation (web-specific issues go to rgbds-www) rgbasm This affects RGBASM labels Nov 28, 2024
@Rangi42 Rangi42 added this to the v0.9.0 milestone Nov 28, 2024
@Rangi42 Rangi42 requested review from ISSOtm and removed request for ISSOtm November 28, 2024 20:29
@Rangi42 Rangi42 marked this pull request as draft November 28, 2024 20:35
@Rangi42 Rangi42 requested a review from ISSOtm November 28, 2024 20:53
@Rangi42 Rangi42 marked this pull request as ready for review November 28, 2024 20:53
@nummacway
Copy link

I propose adding that A and the value added to/substracted from it must have been BCD for doing the previous instruction.

Decimal Adjust Accumulator to restore a [or: the] correct BCD representation [of the value in register A] after adding or substracting a BCD value to/from a BCD value in A [or: addition or substraction of two BCD values].

Explicitly naming additions and substractions also excludes CP, which is listed as an arithmethic instruction by the same document.

@Rangi42
Copy link
Contributor Author

Rangi42 commented Nov 28, 2024

There is no such requirement to use DAA with BCD values, nor to use it only after ADD/SUB/ADC/SBC instructions. That's the obvious/intended use case, but there are others.

ISSOtm
ISSOtm previously requested changes Nov 28, 2024
Copy link
Member

@ISSOtm ISSOtm left a comment

Choose a reason for hiding this comment

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

Thank you for this write-up!

Copy link
Member

@ISSOtm ISSOtm left a comment

Choose a reason for hiding this comment

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

Thank you!

Co-authored-by: Eldred Habert <[email protected]>
@Rangi42 Rangi42 merged commit a5d18d6 into gbdev:master Nov 29, 2024
22 checks passed
@Rangi42 Rangi42 deleted the daa branch November 29, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This affects the documentation (web-specific issues go to rgbds-www) rgbasm This affects RGBASM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document the DAA instruction behavior
3 participants