• C

interrupt within interrupt

1. how do i issue an interrupt within an interrupt
2. i read omewhere it cant be done .if true why?
3. i tried changing registers directly(eg. _AX=0x3d;)
   and then calling the required interrupt function(eg.   (*int21)(); ) here int21 points to the 0x21 int. vector.
   but it didn't work possibly because the changed regidters   affect the rest of the program
4. if you advise me to copy back the reg. values please specify how?
Who is Participating?
bculverConnect With a Mentor Commented:
Technically issuing an interrupt from within an interrupt handler is just like calling a function from within another function, it can be done. The problems lie in the interrupt handlers themselfs. Int 0x21 is whats called non re-entrant. that is you can not make a  int 0x21 call while your in a  0x21 section of code. For example; if you wrote an interrupt handler, that say saves the ax register to a location, changes the ax reg value and  makes a call to itself, the original ax value will be lost. The same thing happens in a DOS 0x21 handler. But you say your not in an int 0x21 handler, so how can this be! Wrong! the operating system spends most of its life spinning around inside int 0x21 functions and like it or not 99 times outa 100 your interrupt handler was called while  in a  int 0x21 function. Luckily there are actually ways to tell this or TSR's would never have been invented. The problem is that there is no easy solution to what you are tring to do in the space available here. (There have been whole books written on this subject). A good place to start would to disect some TSR code and note the ways that they figure out if they came from within an int 0x21 function. Another is to get ahold of a book call "Undocumented DOS" (sorry don't remember the author) that will help you understand some of the undocumented functions called needed for TSR's to work correctly.
It is just not true that you can't call an interupt from another interupt. TSR's and interupt hooking modules hook interupts to call other interupts.

What experience do you have with Assembler? Setting AH=0x3D and calling INT 21 should open a file provided that you put the name of the file in DS:DX and the access type in AL.

Also, calling DOS functions from Windows can have spurious results. Windows emulates DOS and not all functionality is completely the same as if run in DOS alone.

the_shrinkAuthor Commented:
THanks to culver
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.