Use swap in stead of 4 rotations in BCD lesson#123
Merged
avivace merged 1 commit intogbdev:masterfrom Jul 8, 2025
Merged
Conversation
quinnyo
approved these changes
May 2, 2025
Contributor
quinnyo
left a comment
There was a problem hiding this comment.
It's a good change for the code. And I think a reader that doesn't know either swap or rrca might even have an easier time with the single swap.
| rrca | ||
| rrca | ||
| rrca | ||
| swap a ; Move the upper nibble to the lower nibble (divide by 16) |
Contributor
There was a problem hiding this comment.
This comment just explains what swap does (rather than why it's being used). Perhaps mention e.g. "move the tens digit to the low nibble"
Also, now that I think about it, 'divide by 16' might be a bit confusing in the context -- it's a divide by ten in BCD.
avivace
approved these changes
May 6, 2025
Member
avivace
left a comment
There was a problem hiding this comment.
LGTM, @hollannikas maybe just solve the issue that @quinnyo raised?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think this saves bytes, cycles and doesn't mess with the carry flag.