Table Of Contents
Previous Section Next Section

Program 109: Short Time Revisited

The programmer attempted to fix Program 108 by changing the multiplication factors to variables. But the loop is still too short. What's happening?

  1 /***********************************************
  2  * bit_delay -- Delay one bit time for         *
  3  *      serial output.                         *
  4  *                                             *
  5  * Note: This function is highly system        *
  6  *      dependent. If you change the           *
  7  *      processor or clock it will go bad.     *
  8  ***********************************************/
  9 void bit_delay(void)
 10 {
 11     int i;      // Loop counter
 12     int result; // Result of the multiply
 13
 14     // Factors for multiplication
 15     int factor1 = 12;
 16     int factor2 = 34;
 17
 18     // We know that 1863 multiples
 19     // delay the proper amount
 20     for (i = 0; i < 1863; ++i)
 21     {
 22         result = factor1 * factor2;
 23     }
 24 }

(Next Hint 107. Answer 89.)

Table Of Contents
Previous Section Next Section