asm clobber arg for AIX

David Edelsohn dje@watson.ibm.com
Fri Dec 1 17:32:00 GMT 2006


> The AIX assembler uses "1" for register 1 -- which surprised me.  I  
> thought it accepted both 1 and r1.

	It accepts "r1", if one adds something like

.set r1,1

at the beginning of the file.

> Anyhow, in one of my asm statements, I want to specify that register  
> 1 (the stack pointer) is being changed.  So I did this (so far)
>
>          asm("lwz 1, %0" : : "rm" (newbase));
>
> I put "rm" as the constraint because it can be either a register or a  
> memory location.
> Should I just put "m"?  GCC (4.0.2) seems to produce the same code  
> either way.

	The "lwz" instruction only accept a memory address.  This is why
the string is called a "constraint" -- it constrains the operand to the
allowed input.

> Also, should I put "1" as being clobbered? Like:
>
>          asm("lwz 1, %0" : : "m" (newbase) : "1" );

	Yes, you need to inform the compiler that you are modifying the
value of the register.

	You probably should not be modifying the stack this way, but it is
up to you to debug your application.

David



More information about the Gcc-help mailing list