You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example depicts an use-case of inline assembly that may be found in real applications. However, the problem with this example is that the only instruction demonstrated, syscall, doesn't require that its operands get specified. This means that it can't illustrate how to use named input and output constraints to specify instruction parameters. I'd argue that showing how to use these in an example is more important than using an instruction that would often be found in the wild. (I, myself, have been confused by this example.)
I'd suggest an example that looks more like this: (This may not be a definitive example, but it should illustrate my point.)
Besides showing how to use named inputs and outputs, it also shows the order of operands and how to use non-specific registers. Both can be learnt about by looking elsewhere outside of zig's own docs, and the former is platform-specific, so we can't document it for every platform, but I still think it's better to show them in the example than not. (I actually considered filing an issue to allow non-specific registers for inline asm until I did some actual research, because of how useful they are for writing near-zero-overhead bindings for instructions.)
The text was updated successfully, but these errors were encountered:
I'm not sure how necessary this is with current syntax, given that we ripped it wholesale from LLVM. If anything, I'd say we could do with less detail, and a note pointing interested readers to the relevant LLVM docs, so people don't think it was a deliberate compatibility decision. We will need our own assemblers at some point, so we have a chance to create our own syntax; #215 has some ideas for that, and #5241 has a concrete plan.
The example for inline assembly currently found in the documentation looks like this:
The example depicts an use-case of inline assembly that may be found in real applications. However, the problem with this example is that the only instruction demonstrated,
syscall
, doesn't require that its operands get specified. This means that it can't illustrate how to use named input and output constraints to specify instruction parameters. I'd argue that showing how to use these in an example is more important than using an instruction that would often be found in the wild. (I, myself, have been confused by this example.)I'd suggest an example that looks more like this: (This may not be a definitive example, but it should illustrate my point.)
Besides showing how to use named inputs and outputs, it also shows the order of operands and how to use non-specific registers. Both can be learnt about by looking elsewhere outside of zig's own docs, and the former is platform-specific, so we can't document it for every platform, but I still think it's better to show them in the example than not. (I actually considered filing an issue to allow non-specific registers for inline asm until I did some actual research, because of how useful they are for writing near-zero-overhead bindings for instructions.)
The text was updated successfully, but these errors were encountered: