1 #include <stdio.h> 2 3 int main() 4 { 5 #if (_MIPS_ARCH_OCTEON) 6 int t1 = 0; 7 int t2 = 0; 8 __asm__ volatile( 9 ".set noreorder" "\n\t" 10 "move $t0, $zero" "\n\t" 11 "label2:" "\n\t" 12 "addiu $t0, $t0, 1" "\n\t" 13 "bbit0 $t0, 0x3, label2" "\n\t" 14 "nop" "\n\t" 15 "move %0, $t0" "\n\t" 16 ".set reorder" "\n\t" 17 : "=r" (t1) 18 : 19 : "t0"); 20 __asm__ volatile( 21 ".set noreorder" "\n\t" 22 "li $t0, 0xff" "\n\t" 23 "label1:" "\n\t" 24 "addiu $t0, $t0, -1" "\n\t" 25 "bbit1 $t0, 0x3, label1" "\n\t" 26 "nop" "\n\t" 27 "move %0, $t0" "\n\t" 28 ".set reorder" "\n\t" 29 : "=r" (t2) 30 : 31 : "t0"); 32 33 printf("TEST bbit0: %s\n", t1 == 0x08 ? "PASS" : "FAIL"); 34 printf("TEST bbit1: %s\n", t2 == 0xF7 ? "PASS" : "FAIL"); 35 36 long int lt1 = 0; 37 long int lt2 = 0; 38 long int lt3 = 0xff00000000; 39 long int lt4 = 0x100000000; 40 /* Take 0x100000000 and loop until 35th bit is set 41 by incrementing 0x100000000 at a time. */ 42 __asm__ volatile( 43 ".set noreorder" "\n\t" 44 "move $t0, $zero" "\n\t" 45 "move $t1, %1" "\n\t" 46 "label4:" "\n\t" 47 "dadd $t0, $t0, $t1" "\n\t" 48 "bbit032 $t0, 0x3, label4" "\n\t" 49 "nop" "\n\t" 50 "move %0, $t0" "\n\t" 51 ".set reorder" "\n\t" 52 : "=r" (lt1) 53 : "r" (lt4) 54 : "t0", "t1"); 55 /* Take 0xff00000000 and loop until 35th bit is cleared 56 by decrementing 0x100000000 at a time. */ 57 __asm__ volatile( 58 ".set noreorder" "\n\t" 59 "move $t0, %1" "\n\t" 60 "move $t1, %2" "\n\t" 61 "label3:" "\n\t" 62 "dadd $t0, $t0, $t1" "\n\t" 63 "bbit132 $t0, 0x3, label3" "\n\t" 64 "nop" "\n\t" 65 "move %0, $t0" "\n\t" 66 ".set reorder" "\n\t" 67 : "=r" (lt2) 68 : "r" (lt3), "r" (-lt4) 69 : "t0", "t1"); 70 71 printf("TEST bbit032: %s\n", lt1 == 0x0800000000 ? "PASS" : "FAIL"); 72 printf("TEST bbit132: %s\n", lt2 == 0xF700000000 ? "PASS" : "FAIL"); 73 74 #endif 75 return 0; 76 } 77