getvect, setvect
Gets and sets interrupt vector.
Defined in header <dos.h>
Syntax
#include <dos.h>
void interrupt(*getvect(int interruptno)) ();
void setvect(int interruptno, void interrupt (*isr) ());
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
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.
getvect reads the value of the interrupt vector given by interruptno and returns that value as a (far) pointer to an interrupt function. The value of interruptno can be from 0 to 255.
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.
bo^
If you use the prototypes declared in dos.h, simply pass the address of an interrupt function to setvect in any memory model.
Return value
getvect returns the current 4-byte value stored in the interrupt vector named by interruptno.
setvect does not return a value.
See also
Example
#include <stdio.h>
#include <dos.h>
#ifdef _cplusplus
#def ine _CPPARGS ...
telse
#define _CPPARGS
#endif
void interrupt get_out ( CPPARGS); /* interrupt prototype */
void interrupt (*oldfunc)( CPPARGS); /* interrupt function pointer */
int looping = 1;
int main (void)
{
putsC'Press <Shift><Prt So to terminate");
/* save the old interrupt */
oldfunc = getvect (5);
/* install interrupt handler */
setvect (5,get_out);
/* do nothing */
while (looping);
/* restore to original interrupt routine */
setvect (5,oldfunc);
puts("Success") ;
return 0;
void interrupt get_out (_CPPARGS)
{
looping =0; /* change global variable to get out of loop */
}
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/dos.h/getvect/
· short form /3.1/getvect/