[comp.os.msdos.programmer] int 70h

jfjr@mbunix.mitre.org (Freedman) (01/12/91)

  I think I need to know all there is to know about int 70,
the user real time clock interrupt. There is very little
documentation on it. Can I make it my very own? Does
anything use it? The available documentation seems to
indicate that I can adjust the frequency of it - how?
What ranges are available? 

                             Jerry Freedman,Jr

jfjr@mbunix.mitre.org (Freedman) (01/16/91)

  I need to get a timer of about 1 millisecond granularity.
My first impulse was to check out int 70h. Since then
a very kind soul (Greg Montgomery) sent me some code
that speeds up the system timer - hooks int 8. I got
this working fine but just for my own self I tried
hooking int 70 anway (oops COmpaq 382/203 runnung dos 3.31)
and it doesn't look as though its even implemented. 
Has anyone any experience with this particular interrupt?
Its not very well documented which leads be to beleive
that it might not even be there.

                           Jerry Freedman,Jr

davep@gapos.bt.co.uk (Dave Parkinson) (01/16/91)

jfjr@mbunix.mitre.org (Freedman) writes:


>  I need to get a timer of about 1 millisecond granularity.
>  My first impulse was to check out int 70h. Since then

I just depends what you're after.....

The system tick interrupt (18.2 times a second) is derived from timer 0.
this divides its input clock (1.19318MHz) by 65536 to provide the system
tick interrupt.  The internal divisor registers are readable, and thus
it is possible to work out how far you are between system ticks.  (It is 
some time since I used this feature and I seem to recall I had a problem
in this area - using it as an absolute timer).

Some years ago I used this technique to provide a delay routine that
worked with a resolution of 1 ms.  I don't know if you're after an
accurate timer or an accurate delay......

davep@gapos.bt.co.uk

ctl8588@summa.tamu.edu (LAUGHLIN, CHET) (01/19/91)

In article <1991Jan18.134311.13490@linus.mitre.org>, jfjr@mbunix.mitre.org (Freedman) writes...
>vector with the dos_getvect,dos_setvect sequence. I am not getting
>into the interrupt routine period. After reading whatever
>documentation I could get my hands on (very, very sparse) I saw
>that int 70h is used by a couple of services of int 15h (event
>wait and delay) both of which are intended for multi-tasking purposes.
>It really looks to me that its not really there - at least for
>the compaq. If someone has actually used this successfully I
>would love to communicate with them. I have a working solution
>to my problem (speeding up the system timer) but I still
>would rather use int 70 if possible. Some of this text
>is rattling on so the news program will accept it.
>                         Jerry Freedman,Jr

I used the following with success on PS/2s and ATs without problems.
Notice that the manuals are not very clear on the subject of enabling
this interrupt.  Don't forget to include the right support files for
the interrupt calls.  I hope this helps.
+---------------------------------------------------------------+
| Chet Laughlin                  CTL8588@RIGEL.TAMU.EDU         |
|   "I have no opinions as I          (128.194.4.4)             |
|    do not exist, my lawyers                                   |
|    told me so."                                               |
+---------------------------------------------------------------+

---------------------------CUT HERE-----------------------
int dos_flag;                 /* dummy flag DOS plays with */
void (interrupt far *old_int_handle)();
unsigned long timer_count;    /* simple timer */

/*
 * Prog_Control
 *
 * Called by DOS int 70h once every 1/1024 seconds
 */
void interrupt Prog_Control()
{
                                       /* do something quickly */
   ++timer_count;                      /* simple timer */
   _chain_intr(old_int_handle);        /* move on to others in the INT chain*/
}


/*
 * Start_Control
 *
 * hook into Int 70h chain so Dos will call us.  Then tell Dos to
 * start making the calls.
 */
Start_Control()
{
   union REGS regs;
   union SREGS segs;

   old_int_handle = _dos_getvect(0x70);       /* remember old INT chain */
   _dos_setvect(0x70,Prog_Control);           /* install program routine */
   regs.h.ah = 0x83;                          /* set function */
   regs.x.cx = 0xFFFF;                        /* call us till hell freezes */
   regs.x.dx = 0xFFFF;
   segs.es = FP_SEG(dos_flag);                /* point to dummy flag */
   regs.x.bx = FP_OFF(dos_flag);              /* set by DOS */
   int86x(0x15,&regs,&regs,&segs);            /* start calling...*/
}

/*
 * Stop_Control
 *
 * Take the program out of the INT chain softly so we can exit the
 * program without killing DOS in the process
 */
Stop_Control()
{
   regs.h.ah = 0x83;                    /* pick DOS fuction...*/
   regs.x.cx = 0x0000;                  /* only call me once more please */
   regs.x.dx = 0x0001;                  /* then leave me alone */
   segs.es = FP_SEG(dos_flag);          /* point to DOS dummy flag */
   regs.x.bx = FP_OFF(dos_flag);
   int86x(0x15,&regs,&regs,&segs);      /* now stop it....*/
   _dos_setvect(0x70,old_int_handle);   /* and get out of the chain */
}