vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

loop.c (633B)


      1 
      2 int test1()
      3 {
      4 	int n;
      5 	
      6 	asm volatile(
      7 		"movl $0, %%eax\n"
      8 		"movl $20, %%ecx\n"
      9 		"1:\n"
     10 		"incl %%eax\n"
     11 		"loop 1b\n"
     12 		: "=a" (n)
     13 		: "c" (0));
     14 
     15 	if(n != 20)
     16 		return 1;
     17 	return 0;
     18 }
     19 
     20 int test2()
     21 {
     22 	int n;
     23 	
     24 	asm volatile(
     25 		"movl $20, %%eax\n"
     26 		"movl $20, %%ecx\n"
     27 		"1:\n"
     28 		"decl %%eax\n"
     29 		"loopnz 1b\n"
     30 		: "=a" (n)
     31 		: "c" (0));
     32 
     33 	if(n != 0)
     34 		return 1;
     35 	return 0;
     36 }
     37 
     38 int test3()
     39 {
     40 	int n;
     41 	
     42 	asm volatile(
     43 		"movl $20, %%eax\n"
     44 		"movl $20, %%ecx\n"
     45 		"1:\n"
     46 		"decl %%eax\n"
     47 		"loopz 1b\n"
     48 		: "=a" (n)
     49 		: "c" (0));
     50 
     51 	if(n != 1)
     52 		return 1;
     53 	return 0;
     54 }
     55 
     56 int
     57 main(void)
     58 {
     59 	return test1() ||
     60 		test2() ||
     61 		test3();
     62 }