Skip to content

Use swap in stead of 4 rotations in BCD lesson #123

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hollannikas
Copy link
Contributor

I think this saves bytes, cycles and doesn't mess with the carry flag.

Copy link
Contributor

@quinnyo quinnyo left a comment

Choose a reason for hiding this comment

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

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Member

@avivace avivace left a comment

Choose a reason for hiding this comment

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

LGTM, @hollannikas maybe just solve the issue that @quinnyo raised?

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.

3 participants