pkivolowitz/asm_book

2nd literals example format incorrect?

gitonthescene opened this issue · 3 comments

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?

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.

A bit of amplification added.

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.