⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isc.cpp

📁 这是一个C++编程文档
💻 CPP
字号:
///////////////////////////////////////////////////////////////////////////
//                                                                       //
//            File: Isc.cpp                                              //
//            started on: 5/2/92                                         //
//                                                                       //
///////////////////////////////////////////////////////////////////////////
//                                                                       //
//                             V3.66                                     //
//                           ---------                                   //
//                                                                       //
///////////////////////////////////////////////////////////////////////////
//                                                                       //
//                      by Ofer Laor (AKA LeucroTTA)                     //
//                                                                       //
///////////////////////////////////////////////////////////////////////////

#include "isc.h";    // ISC.
#include <dos.h>     // MK_FP, keep, setvect, getvect.

#ifndef __NOT_TSR__
        #include <alloc.h>   // heapwalk.
#endif

// static variables...
char *ISC::StackFrame;
unsigned long ISC::StackFrameLen= 3000; //default stack len.
int ISC::ISCcount= 0;

// overload this function to handle software interrupts...
//
void ISC::isr (IREGS& /* regs */)
{
     // by default this function will make a stack frame of 3000 bytes
     // for the hardware isr's to use.

     static unsigned char recursive= 0;
     static unsigned old_ss, old_sp;
     static ISC* me;

     if (recursive) {
        isr();
        return;
     }
     // put up a new stack frame...
     recursive++;

     disable();

     me= this; // remember this...

     //This code moves the stack to another plane, please do not single
     //  step through this code (Turbo Debugger might not survive having lost
     //  some of it's variables)!

     old_ss= _SS;
     old_sp= _SP;

     _SS= FP_SEG(&StackFrame[StackFrameLen-1]);
     _SP= FP_OFF(&StackFrame[StackFrameLen-1]);

     //On this new Stack Frame You may not use local functions except in this
     //  context:- me->local_function(); - this is because this function's
     //  "this" is in the old stack frame!!! Also use static variables only
     //  (the automatic ones are in the old stack frame context). These points
     //  are only relevant IN THIS ONE FUNCTION:- you can easily call another
     //  local function to do all the stuff for you (me->do_it() may use
     //  automatic variables!!!).


     // call my isr routine...
     me->isr();

     disable();

     _SS= old_ss;
     _SP= old_sp;

     recursive--;
}

// overload this function to handle hardware interrupts...
//
void ISC::isr (void)
{
    old_vect(); // default will not work on software interrupts!!!
}


// ISCThunk.ASM routines.
//
extern "C" {
       void far * far ThunkSet(void far *);
       unsigned far   ThunkSize(void);
       void far * far ThunkGetID(void);
}

// this is the dispatcher called by asm code to call the correct object's
// isr functions.
void interrupt ISCDispatch(unsigned bp, unsigned di, unsigned si,
                           unsigned ds, unsigned es, unsigned dx,
                           unsigned cx, unsigned bx, unsigned ax,
                           unsigned ip, unsigned cs, unsigned flags)
{
   ISC* isc= (ISC *)ThunkGetID();

   IREGS regs;

   regs.x.bp= bp;
   regs.x.di= di;
   regs.x.si= si;
   regs.x.ds= ds;
   regs.x.es= es;
   regs.x.dx= dx;
   regs.x.cx= cx;
   regs.x.bx= bx;
   regs.x.ax= ax;
   regs.x.ip= ip;
   regs.x.cs= cs;
   regs.x.flags= flags;

   // software dispatch();

   isc->isr(regs); // software later...

   bp= regs.x.bp;
   di= regs.x.di;
   si= regs.x.si;
   ds= regs.x.ds;
   es= regs.x.es;
   dx= regs.x.dx;
   cx= regs.x.cx;
   bx= regs.x.bx;
   ax= regs.x.ax;
   ip= regs.x.ip;
   cs= regs.x.cs;
   flags= regs.x.flags;
}

// 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -