Solved

chaining interrupts

Posted on 1997-08-06
3
457 Views
Last Modified: 2008-03-06
How do I chain interrupts in C++? I am using Borland, and I want to use the tick timer.  Does the "interrupt handler" func handle this for me?
0
Comment
Question by:kellyjj
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
md041797 earned 50 total points
ID: 1166958
If you're talking about DOS, just use getvect to get the old interrupt vector and then setvect to install your handler.  Disable interrupts during setvect.  Your handler executes and then jmp to the old vect.  Reverse the process to install.


/* * * * * * * * * * * * * * *
NOTE: This is an interrupt service routine.  
You can NOT compile this program with
Test Stack Overflow turned on and get an
executable file that will operate correctly.
 * * * * * * * * * * * * * * */


#include <stdio.h>
#include <dos.h>
#include <conio.h>



#define INTR 0X1C    /* The clock tick interrupt */

#ifdef __cplusplus
    #define __CPPARGS ...
#else
    #define __CPPARGS
#endif

void interrupt ( *oldhandler)(__CPPARGS);

int count=0;

void interrupt handler(__CPPARGS)
{
/* increase the global counter */
   count++;

/* call the old routine */
      oldhandler();
}
      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;
}
0
 
LVL 4

Expert Comment

by:md041797
ID: 1166959
Revise that.  setvect disable interrupts for you, so forget about that part.
0
 
LVL 2

Author Comment

by:kellyjj
ID: 1166960
thanks,  
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now