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

2nd literals example format incorrect? #28

Closed
gitonthescene opened this issue Jul 4, 2024 · 3 comments
Closed

2nd literals example format incorrect? #28

gitonthescene opened this issue Jul 4, 2024 · 3 comments

Comments

@gitonthescene
Copy link

Just reading through section_2/float/literals and there is a call to printf, but it looks like only registers x0 and x2 have been set though the format takes an int and two floats. Are the two floats d0 and d1? If so then it's not clear to me by what mechanism they get passed as the third and fourth argument.

Perhaps the passing arguments section could include an example of passing floats?

@pkivolowitz
Copy link
Owner

Lines 19 through 21 put doubles into d0 and d1. printf %f only prints doubles, by the way. That's why the floats are converted to doubles. Note this code is Linux only. Had it been Mac, x1, d0 and d1 would have to be put on the stack. I will amplify the comments about this code.

@pkivolowitz
Copy link
Owner

A bit of amplification added.

@gitonthescene
Copy link
Author

Thanks. Part of what confuses me is that in C the floats would be the third and fourth argument which I would have guessed should be d2 and d3 rather than d0 and d1.

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