3 ms·
Sorry, somewhat of a tangent but regarding: > The %0 and %1 are positional references into a list you have to count by hand. You can name your operands in gcc
by Krssst 3mo ago
Sorry, somewhat of a tangent but regarding:
> The %0 and %1 are positional references into a list you have to count by hand.
You can name your operands in gcc inline assembly.
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Output-Operands https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Output-...
Look for "asmSymbolicName".
On a phone so not checking if it builds, but something like `asm("add %[my_out], %[my_in], #3":[my_out]"=r"(outvar):[my_in]"r"(invar):);`.
- gingerBill 3mo agoThe equivalent Odin syntax looks like this: add_three :: asm(my_in: u64) -> (my_out: u64) { add my_out, my_in, 3 } out_var = add_three(in_var) Which is already infinitely more readable and requires no parochial sigils nor the arcane clobbering syntax.
- layer8 3mo agoThe parent was objecting to the syntax allegedly forcing one to use “positional references into a list you have to count by hand”. Being inaccurate in your criticism just makes it appear questionable as a whole.
- astrange 3mo agoThe issue is you're usually using inline asm for special cases, or else CPU features so new the compiler doesn't know about them. Which means it also doesn't know the clobbering rules. That's why it looks like an escape hatch. It is one!