[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A few Decstation questions.



On Wed, Apr 09, 2003 at 09:37:48AM -0400, Len Sorensen wrote:
> On Wed, Apr 09, 2003 at 12:40:28AM +0200, Guido Guenther wrote:
> > Please try:
> >  http://honk.physik.uni-konstanz.de/linux-mips/kernels/kernel-image-2.4.19-r3k-kn02_2.4.19-0.020911.7_mipsel.deb 
> 
> Is there any way to write a small assembly program that tests for ll/sc
> support, rahter than trying to instlal libc6 2.3.1 and smashing the
> system to bits? :)
> 
> It has been a long time since I did MIPS assembly in school.
The attached example is an atomic add and should give an illegal
instruction on mips1 CPUs for which we don't emulate ll/sc in the
kernel.
Regards,
 -- Guido
#include <stdio.h>

int main()
{
	volatile int a = 0xce9dae9f;
	volatile int b = 0x10101010;
	volatile int tmp;

	printf("0x%x + 0x%0x = ", a, b );
         __asm__ __volatile__
	( ".set mips2\n\t"
	  "1:\n\t"
	  "ll	%0,%2\n\t"
	  "addu	%0,%3,%0\n\t"
	  "sc	%0,%1\n\t"
	  "beqz	%0,1b\n\t"
	  ".set mips1\n\t"
          : "=&r"(tmp), "=m"(a)
          : "m" (a), "r"(b)
          : "memory");
   printf(" 0x%x\n", a);
}

Reply to: