Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

chaining interrupts

Posted on 1997-08-06
3
Medium Priority
?
477 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 100 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

972 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