Solved

chaining interrupts

Posted on 1997-08-06
3
466 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 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