home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 5.ddi / CLIBSRC2.ZIP / GETVECT.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  2.7 KB  |  84 lines

  1. /*---------------------------------------------------------------------------
  2.  * filename - getvect.cas
  3.  *
  4.  * function(s)
  5.  *        getvect - gets interrupt vector entry
  6.  *        setvect - sets interrupt vector entry
  7.  *--------------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #pragma inline
  19. #include <asmrules.h>
  20. #include <dos.h>
  21. #include <stdlib.h>
  22.  
  23. /*--------------------------------------------------------------------------*
  24.  
  25. Name            getvect - gets interrupt vector entry
  26.  
  27. Usage           void interrupt(far *getvect(int intr_num)) ( );
  28.  
  29. Prototype in    dos.h
  30.  
  31. Description     MS-DOS includes a set of "hard-wired" interrupt
  32.                 vectors, numbered 0 to 255. The 4-byte value in each vector
  33.                 is actually an address, which is the location of an interrupt
  34.                 function.
  35.  
  36.                 getvect reads the value of the vector named by intr_num and
  37.                 interprets that value read as a (far) pointer to some
  38.                 interrupt function.
  39.  
  40. Return value    getvect returns the current 4-byte value stored in
  41.                 the interrupt vector named by intr_num.
  42.  
  43. *---------------------------------------------------------------------------*/
  44. void interrupt (far * _CType getvect(int intr))()
  45. {
  46. asm     mov     ah, 035h
  47. asm     mov     al, intr
  48. asm     int     021h
  49. asm     xchg    ax,bx
  50. asm     mov     dx,es
  51.  
  52.         return( (void interrupt (*)()) (MK_LONG) );
  53. }
  54.  
  55.  
  56. /*--------------------------------------------------------------------------*
  57.  
  58. Name            setvect - sets interrupt vector entry
  59.  
  60. Usage           void setvect(int intr_num, void interrupt (*isr)( ));
  61.  
  62. Prototype in    dos.h
  63.  
  64. Description     setvect sets the value of the vector named by intr_num to a
  65.                 new value, vector, which is a far pointer containing the
  66.                 address of a new interrupt function. The address of a C
  67.                 routine may only be passed to vector if that routine is
  68.                 declared to be an interrupt routine.
  69.  
  70.                 Note: If you use the prototypes declared in dos.h, you can
  71.                 simply pass the address of an interrupt function to setvect
  72.                 in any memory model.
  73.  
  74. *---------------------------------------------------------------------------*/
  75. void _CType setvect(int intr, void interrupt (far *func)())
  76. {
  77. asm     mov     ah, 025h
  78. asm     mov     al, intr
  79. asm     push    ds
  80. asm     lds     dx, dword ptr func
  81. asm     int     021h
  82. asm     pop     ds
  83. }
  84.