[M3devel] cas/casp?

Jay K jay.krell at cornell.edu
Fri Dec 18 19:04:27 CET 2009


Tony is this right?

 

 

conceptually:

 

 

result := CAS(VAR destination, compare, exchange)

 

 

old := destination

if old := compare then

  destination = exchange

return old

 

 

bool result := CASP(VAR destination, compare, exchange)

P for predicate aka returning bool

 

 

old := destination

if old = compare then

  destination := exchange

  return true

return false

 

 

I'm pretty sure it is.

 

 

I'll have this for 16 bit and 32 bit values shortly, for now requiring

a recent Microsoft compiler and it generates function calls.

But inlining should be easy enough.

And then 8bit and 64bit.

 

 

Also this will probably not work on 386 or 486 but require Pentium or somesuch.

I don't know when various instructions were introduced but I know

386 is much poorer here than modern processors.

 

 

I assume only support int8, uint8, int16, uint16, int32, uint32, int64, uint64, size_t, ptrdiff_t

and not e.g. floating point.

 

 

 - Jay
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20091218/33d71546/attachment-0001.html>


More information about the M3devel mailing list