Xref: news-dnh.mv.net comp.os.msdos.djgpp:155 Path: news-dnh.mv.net!mv!news.sprintlink.net!cs.utexas.edu!bcm!news.msfc.nasa.gov!news.larc.nasa.gov!lerc.nasa.gov!lerc.nasa.gov!babar!gantose From: gantose AT lerc DOT nasa DOT gov (Dave Gantose) Newsgroups: comp.os.msdos.djgpp Subject: [HELP] New int handler messes up fprintf Date: Tue, 6 Jun 1995 11:26:12 Organization: NASA Lewis Research Center Lines: 73 Nntp-Posting-Host: babar.lerc.nasa.gov To: djgpp AT sun DOT soe DOT clarkson DOT edu Dj-Gateway: from newsgroup comp.os.msdos.djgpp In my program, I install a new interrupt handler for the system timer (int 8) so that I can get 64 ticks per second. After a while, I put the old interrupt handler back. Later in the program, when I try to fprintf some values, the program crashes with "Unsupported INT 0x0d". The traceback indicates that the problem occurred at the fprintf call from my program (_fprintf+103). Is there something I need to reset, or clear, or watch out for after I have set and reset the timer interrupt handler? The FAQ kind of alludes to this, but I didn't understand that part. Thanks for any info. My general steps are summarized below: static _go32_dpmi_registers regs; static _go32_dpmi_seginfo old_rm_isr, old_pm_isr, new_rm_isr, new_pm_isr; static BOOL bTicked; int main() { cprintf ("\r\nHit a key to start."); getkey(); startInterrupts(); stopInterrupts(); for (j=0; j<512; j++) fprintf (stdout, "%d\n", j); return 0; } void tick () { bTicked = TRUE; outportb (0x20,0x20); } void startInterrupts () { disable(); outportb (0x43,0x36); //set up timer control register outportb (0x40,CounterLSB); //load low byte of count outportb (0x40,CounterMSB); //load hi byte of count //Install real-mode handler new_rm_isr.pm_offset = (ULONG) tick; _go32_dpmi_get_real_mode_interrupt_vector(0x08, &old_rm_isr); _go32_dpmi_allocate_real_mode_callback_iret(&new_rm_isr, ®s); _go32_dpmi_set_real_mode_interrupt_vector(0x08, &new_rm_isr); //Install protected-mode handler new_pm_isr.pm_offset = (ULONG) tick; _go32_dpmi_get_protected_mode_interrupt_vector (0x08, &old_pm_isr); _go32_dpmi_allocate_iret_wrapper(&new_pm_isr); new_pm_isr.pm_selector = _go32_my_cs(); _go32_dpmi_set_protected_mode_interrupt_vector(0x08, &new_pm_isr); enable(); } void stopInterrupts () { disable(); outportb (0x43,0x36); outportb (0x40,0x00); outportb (0x40,0x00); // Restore real-mode handler _go32_dpmi_set_real_mode_interrupt_vector (0x08, &old_rm_isr); _go32_dpmi_free_real_mode_callback (&new_rm_isr); // Restore p-mode handler _go32_dpmi_set_protected_mode_interrupt_vector (0x08, &old_pm_isr); _go32_dpmi_free_iret_wrapper (&new_pm_isr); enable(); } ============================================================================= Dave Gantose ADF, Inc. 2001 Aerospace Pkwy. phone: (216)977-1376 Brook Park, OH 44142 email: Gantose AT lerc DOT nasa DOT gov