Solved

chaining interrupts

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

Independent Software Vendors: 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

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 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.
Suggested Courses

634 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