Fwd: Re: still no accelerated X ($#!$*)

David Edelsohn dje at watson.ibm.com
Sat Jan 22 04:32:39 EST 2000


asm volatile ("stwbrx %1,%2,%3; eieio"
	: "=m" (*(volatile unsigned *)(base_addr+regindex))
	: "r" (regdata), "b" (regindex), "r" (base_addr));

asm volatile ("lwbrx %0,%1,%2; eieio"
	: "=r"(val)
	: "b"(regindex), "r"(base_addr),
	  "m" (*(volatile unsigned *)(base_addr+regindex)));

BTW, one of the main stylistic points which confused me yesterday is that
the inlined assembly statement associates variable "regindex" with the
second parameter of the instruction and varable "base_addr" with the third
parameter of the instruction.  As long as the second parameter is not
assigned to register r0, the two are commucative in their function, so
this is not an error.

	In the instruction architecture, the second parameter is intended
to be the base and the third as the index, so it is confusing for someone
familiar with the POWER and PowerPC instruction set to read the order in
which the parameters are assigned.  Instructions loading from addresses
with displacements, e.g.,

	lwz %0,%1(%2)

specify the displacement second and the base register last, so the
ordering can get confused.  That was what threw me off yesterday in my
haste.

David
===============================================================================
David Edelsohn                                      T.J. Watson Research Center
dje at watson.ibm.com                                  P.O. Box 218
+1 914 945 4364 (TL 862)                            Yorktown Heights, NY 10598

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-dev mailing list