1 #ifndef_M68K_DELAY_H 2 #define_M68K_DELAY_H 3
4 /* 5 * Copyright (C) 1994 Hamish Macdonald 6 * 7 * Delay routines, using a pre-computed "loops_per_second" value. 8 */ 9
10 extern__inline__void__delay(intloops)
/* */ 11 { 12 __asm__("\n\tmovel %0,d0\n1:\tsubql #1,d0\n\tbpls 1b\n"
13 : /* no outputs */ 14 : "g" (loops)
15 : "d0");
16 } 17
18 /* 19 * division by multiplication: you don't have to worry about 20 * loss of precision. 21 * 22 * Use only for very small delays ( < 1 msec). Should probably use a 23 * lookup table, really, as the multiplications take much too long with 24 * short delays. This is a "reasonable" implementation, though (and the 25 * first constant multiplications gets optimized away if the delay is 26 * a constant) 27 */ 28 extern__inline__voidudelay(unsignedlongusecs)
/* */ 29 { 30 asm ("mulul %1,d0,%0\n\t"
31 "divul %2,d0,%0"
32 : "=d" (usecs)
33 : "d" (usecs),
34 "i" (1000000),
35 "0" (loops_per_sec)
36 : "d0");
37 __delay(usecs);
38 } 39
40 #endif/* defined(_M68K_DELAY_H) */