Solved

chaining interrupts

Posted on 1997-08-06
3
474 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VS2015 Redefinition errors 4 103
designing in object programming 12 131
DCT of  2D array using fftw in c++ 9 132
using interface in TLB 3 29
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

734 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