How to setup an ISR in Turbo C++.

Posted on 1997-08-07
Last Modified: 2012-08-13
I'm having problems getting my interrupt service routines to work properly. I use the good old Borland TC and follow the examples when setting up my ISR and when saving old vectors and plugging new ones. But still, it doesn't matter how I excite the IRQ-channels, I never manage to enter the ISR. I use IRQ11 on an embedded 386-system. Can you give mee a hint about what could be the problem, I've run out of ideas.

Fredrik Bagenholm
Question by:e92fb

Accepted Solution

tomii earned 50 total points
Comment Utility
Is that int 0x11, or int 11 ?  (hex, or decimal)...

from "Teach Yourself Game Programming in 21 Days", SAMs Publishing... (with some modifications).

note, that if you change MY_INTERRUPT to 0x1C, that is the system timer, & this will update the counter about 18.2 times per second....

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

#define      MY_INTERRUPT      0x11  /* int 11 hex */

/* Used to hold the old interrupt vector */
void (_interrupt far *Old_Isr)();

long      counter = 0;      /* global for interrupt to use */

void _interrupt far Count_Ints(void)
      /* increment counter whenever interrupt is called */

      /* call the old int handler if there was one (next
            ISR in the chain.  If you want to disable the
            other interrupts (no chain), then do not
            call this next function... WARNING!!  you
            can mess things up doing this, as some
            system processes _need_ some interrupts! */


void main()
      /* save old ISR */
      Old_Isr = _dos_getvect(MY_INTERRUPT);

      /* install my ISR */
      _dos_setvect(MY_INTERRUPT, Counter);

      /* wait for keyhit */
            /* print current value of counter - note that it
            is being changed by th ISR */
            printf("The ISR has been called %ld times", counter);


      /* Replace the old ISR */
      _dos_setvect(MY_INTERRUPT, Old_Isr);


Author Comment

Comment Utility
Hi and thanks!
I've actually managed to get it going, but I had to change the IRQ-mask to enable IRQ10 and IRQ11. This wasn't done by BIOS at start-up as I expected. Also an EOI has to be sent (both to address 0xA0 and 0x20) to the PIC just before leaving the ISR.

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

728 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

9 Experts available now in Live!

Get 1:1 Help Now