Re: Constraint for inline assembly with one register used for both an input variable and an output variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 05, 2025 at 03:55:15PM +0200, Georg-Johann Lay wrote:
> >register int *p1 asm ("r0") = …;
> >register int *p2 asm ("r1") = …;
> >int *result;
> >asm ("sysint" : "+r" (p1) : "0" (p1), "r" (p2));
> >result = p1;
> 
> With "+r" (p1), the input operand "0" (p1) is not needed any more. Just:
> 
> asm ("sysint" : "+r" (p1) : "r" (p2));

That's what I said.  You do need to copy "p1" to "result", the code was
written to expect the result there, better keep the code correct even
when making it more elegant ;-)

Note that + is just syntactic sugar for = 0, you still have an input and
an output operand, but they are automatically tied.

> >(and by choosing better variable names, "r0" and "r1" perhaps, you don't
> >need to write a copy).

^^^


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux