Mail Archives: djgpp/1996/05/14/03:45:06
Hi ;)
I am learning to program on low level. As a first excercise i
decided to program a short interrupt-handler for IRQ2. I wrote
a function wich has an output of an one second durating sound.
I first get the old ivector, then "allocate iret wrapper", then
i have a test period of 20 seconds, then i restore the old ivector.
My proggi compiles fine, but when i am running it,
i get only one sound (when i press serveral keys on the keyboard).
After 20 seconds it comes back to a dos prompt, but something went
wrong with restoring the old vector: the keyboard is still out of
function.
What is my mistake?
Ralf Suessbrich
Here's the code:
#include <dpmi.h>
#include <stdio.h>
#include <dos.h>
keyb_handler () {
nosound();
sound (500);
sleep (1);
nosound ();
}
main () {
_go32_dpmi_seginfo old_handler, my_handler;
printf ("Getting old I-Vector !\n");
_go32_dpmi_get_protected_mode_interrupt_vector (9, &old_handler);
my_handler.pm_offset = (int) keyb_handler;
_go32_dpmi_allocate_iret_wrapper (&my_handler);
printf("\nSeting new I-Vector !");
_go32_dpmi_set_protected_mode_interrupt_vector (9, &my_handler);
printf("\nDONE !!\n\nWaiting now 20 seconds for testing.\n");
sleep (20);
_go32_dpmi_set_protected_mode_interrupt_vector (9, &old_handler);
printf("\n\nOld I-Vector restored ;)\nEnd");
return 0;
}
- Raw text -