Atomic Operation

Ian Lance Taylor ian@zembu.com
Sat Oct 2 18:25:00 GMT 1999


   From: David Williams <davidwilliams@ozemail.com.au>
   Date: Sun, 3 Oct 1999 11:16:17 +1000

   A while ago I got some help to implement some atomic operation using 
   constraints within inline assembler. I now need to do a similar thing but 
   it got complicated. After some trial and error I got the following bit of 
   code to produce the desired assembler - but it seems quite messy. My 
   question is there a better way to produce the same result?

	   asm("	move.L %0,%%d0" : : "m" (InpMasks[digChan]) : "%%d0");
	   asm("	OR.L %%d0,%0" : "m=" (EZ328_IMR) : : "%%d0");

   Note: InpMasks[digChan] references a 32 bit value from an array of 32 bit 
   values. EZ328_IMR is memory address of 32 bit hardware register (interrupt 
   mask register in this case).

You should be able to do something along the lines of
    asm ("or.l %1,%0" : "=m" (EZ328_IMR) : "d" (InpMasks[digChan]))

When gcc sees the `d' constraint on the input operand, it will load
the value into a data register.

Ian

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com



More information about the crossgcc mailing list