This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Atomic Operation


Hi All,

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).

What I am trying to do is use the OR instruction on a memory address. GCC 
seems to prefer to do it in registers and then transfer the result to 
memory. This is no good for atomic OR on hardware register. So I devised 
the above assembler. The OR instruction requies that one of the operands be 
a data register so I had to preload a data register. Then I had to specify 
the register I loaded in the first instruction in the second. To ensure 
that it does not clash with other register usage in the function it is used 
in I specify the data register as being "clobbered" (last argument in the 
asm statement). The selection of the data register to use is arbitrary.

Would I be wiser to use any particular data register and why?

TIA
David Williams.
davidwilliams@ozemail.com.au



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]