Borland C++ reference

_dos_setvect

raw OCR

Sets interrupt vector entry.

Defined in header <dos.h>

Syntax

#include <dos.h>
void _dos_setvect(unsigned   interruptno, void interrupt {*isr) ());

Every  processor of the 8086 family includes a set of interrupt vectors,
numbered   0 to 255. The 4-byte value in each vector is actually an address,
which  is the location of an interrupt function.

_dos_setvect   sets the value of the interrupt vector named by interruptno
to a new value, isr, which is a far pointer containing the address of a new
interrupt function. The address  of a C routine can only be passed  to isr if
that routine is declared to be an interrupt routine.

If you use the prototypes declared  in dos.h, simply pass the address  of an
interrupt function to _dos_setvect  in any memory    model.

Portability

DOSUNIXWindowsANSI CC++ only
■■

Return value

None.

See also

Example

/* This is an interrupt service routine. You can NOT  compile this program with
   Test Stack Overflow turned on and get an executable  file which will operate
   correctly. */
#include <stdio.h>
#include <dos.h>
iinclude <conio.h>

idefine INTR OXIC  /* The clock tick interrupt  */
tifdef   cplusplus
    #def ine _CPPARGS  ...
#else
    Mefine  _CPPARGS
#endif

void interrupt  ( *oldhandler) (_CPPARGS) ;

int count=0;

void interrupt handler {_CPPARGS)
{
   count++;       /* increase the global counter  */
   oldhandlerO ;  /* call the old routine  */

int main(void)
{
   /* save the old interrupt vector */
   oldhandler = getvect (INTR);
   /* install the new interrupt handler */
   setvect(INTR, handler);
   /* loop until the counter exceeds 20 */
   while (count < 20)
      printf("count is %d\n",count );

   /* reset the old interrupt handler */
   setvect(INTR, oldhandler);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `dos setvect` read as `_dos_setvect`