kianusch@unicom.UUCP (Kianusch Sayah-Karadji) (02/07/90)
I've got a problem... My program should read in the keyboard and print it (or do something else) and while it is doing this, it should display a clock on the screen (interrupt)! clock works untill I read something from the keyboard.... Yuk! I get a run-time error R6000... (Stack overflow) the program is in C for the IBM (Microsof 5.1)... HELP!!! thanx.... Kianusch ----- program ---- #include <stdlib.h> #include <stdio.h> #include <dos.h> void cdecl interrupt far new_break(void); void (cdecl interrupt far *old_break)(void); void cdecl interrupt far new_tick(void); void (cdecl interrupt far *old_tick)(void); void gettime (char *, char *, char *); void set_interrupt (void); void bye(void); char hr, min, sec, buf[11]; int count=0, inclock=0; main() { unsigned char ch; set_interrupt(); do { ch = getchar(); putchar (ch); } while (ch != 13); bye(); } void set_interrupt(void) { _disable(); old_tick = _dos_getvect(0x08); old_break = _dos_getvect(0x23); _dos_setvect (0x08, new_tick); _dos_setvect (0x23, new_break); _enable(); gettime (&hr, &min, &sec); } void bye (void) { _disable(); _dos_setvect (0x23, old_break); _dos_setvect (0x08, old_tick); _enable(); exit (1); } void cdecl interrupt far new_tick(void) { if (!inclock) { inclock = 1; if (!count) { count = (((sec%5)==0) ? 19 : 18); if (++sec >= 60) { sec=0; if (++min >= 60) { min=0; if (++hr >= 24) hr = 0; } } printf(buf, " %02d:%02d:%02d ", hr, min, sec); /* printf for simplicity */ } --count; inclock = 0; } _chain_intr (old_tick); } void cdecl interrupt far new_break() { bye(); } void gettime (tmp_hr, tmp_min, tmp_sec) char *tmp_hr, *tmp_min, *tmp_sec; { union REGS regs; regs.h.ah = 0x2c; int86 (0x21, ®s, ®s); *tmp_hr = regs.h.ch; *tmp_min = regs.h.cl; *tmp_sec = regs.h.dh; }