Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  In all PCs and PS/2s, the input oscillator to the system timer circuit has
  a frequency of 1.19318 MHz. On each cycle, the timer chip decrements the
  values in a set of internal 16-bit counters, one for each of the timer's
  output channels. When the value in a counter reaches 0, the chip generates
  a single output pulse on the corresponding channel, resets the count, and
  starts counting down again.

  When the ROM BIOS initializes the system timer, it stores a countdown
  value of 0 in the count register for channel 0. This means that the timer
  chip decrements the counter 216 times between output pulses on channel 0,
  so output pulses occur 1,193,180/65,536, or about 18.2 times per second.
  The output from timer channel 0 is used as the signal on interrupt request
  level 0 (IRQ0), so interrupt 08H occurs whenever channel 0 of the system
  timer counts down to 0--that is, 18.2 times per second.

  The ROM BIOS contains an interrupt handler for interrupt 08H that
  increments a running count of clock ticks at 0040:006CH in the BIOS data
  area. This same interrupt handler also decrements the byte at 0040:0040H;
  if the value in the byte reaches 0, the interrupt handler issues a command
  to the diskette drive controller to turn off the diskette drive motor if
  it's on.

  The ROM BIOS interrupt 08H handler also issues software interrupt 1CH,
  which is intended for use in programs that want to be notified when a
  system timer tick occurs. A program can detect when each timer tick occurs
  simply by pointing the interrupt 1CH vector at 0000:0070H to its own
  interrupt handler. If you use an interrupt 1CH handler in a program,
  however, be aware that the ROM BIOS interrupt 08H handler does not allow
  subsequent clock-tick interrupts on IRQ0 to occur until your interrupt 1CH
  handler returns. If you install an interrupt 1CH handler, be certain that
  it doesn't keep IRQ0 disabled for too long or the system may crash.

  The system timer tick and its interrupt are useful in programs that must
  perform a simple task at a regular interval regardless of what else is
  going on in the computer. The timer-tick interrupt has the highest
  priority of any of the hardware interrupts (except the nonmaskable
  interrupt), so the code in the corresponding interrupt 08H and 1CH
  handlers takes precedence over all other system software.

  For this reason, the timer tick is used primarily in operating system
  software and in memory-resident "pop-up" programs like SideKick or the
  Norton Guides. Such programs have their own timer-tick interrupt handlers
  that check whether it is time to pop up on the screen. These programs
  generally rely on the system timer tick to occur at the default frequency
  of 18.2 ticks per second.

  Because timer-tick function is so essential to the proper operation of the
  computer, you should change the output frequency of system timer channel 0
  only if you are careful to preserve the functionality of the ROM BIOS
  interrupt 08H handler. For example, BASIC uses the timer tick to measure
  the duration of tones created with the PLAY or SOUND command. However,
  because the standard rate of 18.2 ticks per second is not fast enough to
  provide the precision that some kinds of music demand, BASIC reprograms
  the timer to tick four times faster, which causes interrupt 08H to occur
  72.8 times per second instead of 18.2 times per second. When BASIC counts
  against the quadruple rate, it is able to more accurately reproduce the
  proper tempo of a piece of music.

  BASIC can do this because it has a special interrupt 08H handler that
  calls the default interrupt 08H handler on every fourth timer tick. This
  ensures that the usual interrupt 08H functions still occur 18.2 times per
  second. If you reprogram system timer channel 0 to a nonstandard rate,
  your program should use the same technique of preserving interrupt 08H
  functionality.

  Programming system timer channel 2, the sound frequency generator, is not
  as demanding, because no ROM BIOS or operating system functions rely on
  it. Before we cover the programming details, however, we'll describe some
  of the basic mechanics of creating sounds with a computer.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson