1 #ifndef_MIPS_DELAY_H 2 #define_MIPS_DELAY_H 3
4 extern__inline__void__delay(intloops)
/* */ 5 { 6 __asm__(".align 3\n"
7 "1:\tbeq\t$0,%0,1b\n\t"
8 "addiu\t%0,%0,-1\n\t"
9 :
10 :"d" (loops));
11 } 12
13 /* 14 * division by multiplication: you don't have to worry about 15 * loss of precision. 16 * 17 * Use only for very small delays ( < 1 msec). Should probably use a 18 * lookup table, really, as the multiplications take much too long with 19 * short delays. This is a "reasonable" implementation, though (and the 20 * first constant multiplications gets optimized away if the delay is 21 * a constant) 22 */ 23 extern__inline__voidudelay(unsignedlongusecs)
/* */ 24 { 25 usecs *= 0x000010c6; /* 2**32 / 1000000 */ 26 __asm__("mul\t%0,%0,%1"
27 :"=d" (usecs)
28 :"0" (usecs),"d" (loops_per_sec)
29 :"ax");
30 __delay(usecs);
31 } 32
33 #endif/* defined(_MIPS_DELAY_H) */