home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / ISINVINT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  2.3 KB  |  76 lines

  1. /**
  2. *
  3. * Name        isinvint -- Invoke an interrupt service routine
  4. *        (Formerly called PCINVINT.)
  5. *
  6. * Synopsis    ercode = isinvint(intype,preg);
  7. *
  8. *        int ercode      Returned error code (0 if okay,
  9. *                  1 if interrupt type is out of range,
  10. *                  2 if interrupt vector is invalid).
  11. *        int intype      Interrupt type (0 to 255)
  12. *        DOSREG *preg      Pointer to register structure
  13. *
  14. * Description    This function invokes the interrupt service routine
  15. *        associated with the interrupt type intype.  Information
  16. *        may be passed to the service routine via values in the
  17. *        register structure.  The service routine may alter these
  18. *        values for return.  The software interrupt is invoked
  19. *        using ISCALINT.
  20. *
  21. *        This function should not be used to access BIOS or DOS
  22. *        functions because error checking and register setting
  23. *        are not performed.  (For example, the stack segment and
  24. *        pointer are not saved even when that is necessary to
  25. *        avoid certain DOS bugs.) ISINVINT is intended to invoke
  26. *        user-defined software interrupt service routines.  Use
  27. *        the C TOOLS PLUS functions bios() or dos() to access
  28. *        BIOS or DOS functions, respectively.
  29. *
  30. * Returns    ercode          Error code (0 if okay,
  31. *                  1 if interrupt type is out of range,
  32. *                  2 if interrupt vector is invalid).
  33. *        *preg          The values of the registers may be altered
  34. *                  by the service routine.
  35. *
  36. * Version    3.0  (C)Copyright Blaise Computing Inc.  1986
  37. *
  38. **/
  39.  
  40. #include <bisr.h>
  41.  
  42. int isinvint(intype,preg)
  43. int intype;
  44. DOSREG *preg;
  45. {
  46.     ADS    vector;
  47.     ALLREG regs;
  48.  
  49.     if (isretvec(intype,&vector))     /* Get interrupt vector          */
  50.        return 1;              /* Interrupt type out of range  */
  51.  
  52.     regs.ax.x  = preg->ax;
  53.     regs.bx.x  = preg->bx;
  54.     regs.cx.x  = preg->cx;
  55.     regs.dx.x  = preg->dx;
  56.     regs.si    = preg->si;
  57.     regs.di    = preg->di;
  58.     regs.ds    = preg->ds;
  59.     regs.es    = preg->es;
  60.     regs.flags = DEF_FLAGS;
  61.  
  62.     if (iscalint(&vector,®s))
  63.     return 2;              /* Invalid interrupt vector     */
  64.  
  65.     preg->ax = regs.ax.x;
  66.     preg->bx = regs.bx.x;
  67.     preg->cx = regs.cx.x;
  68.     preg->dx = regs.dx.x;
  69.     preg->si = regs.si;
  70.     preg->di = regs.di;
  71.     preg->ds = regs.ds;
  72.     preg->es = regs.es;
  73.  
  74.     return 0;                  /* Success.              */
  75. }
  76.