public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* asm clobber arg for AIX
@ 2006-11-30 22:31 Perry Smith
  2006-12-01 17:32 ` David Edelsohn
  0 siblings, 1 reply; 2+ messages in thread
From: Perry Smith @ 2006-11-30 22:31 UTC (permalink / raw)
  To: MSX to GCC

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

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.

Also, should I put "1" as being clobbered? Like:

         asm("lwz 1, %0" : : "m" (newbase) : "1" );


Thanks,
Perry Smith ( pedz@easesoftware.com )
Ease Software, Inc. ( http://www.easesoftware.com )

Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: asm clobber arg for AIX
  2006-11-30 22:31 asm clobber arg for AIX Perry Smith
@ 2006-12-01 17:32 ` David Edelsohn
  0 siblings, 0 replies; 2+ messages in thread
From: David Edelsohn @ 2006-12-01 17:32 UTC (permalink / raw)
  To: Perry Smith; +Cc: gcc-help

> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-12-01 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-30 22:31 asm clobber arg for AIX Perry Smith
2006-12-01 17:32 ` David Edelsohn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).