microsoft c isr question

D'Arcy J.M. Cain darcy at druid.uucp
Mon Feb 19 04:44:43 AEST 1990


In article <WIENER.90Feb17172147 at stout.stout.UCAR.EDU> wiener at stout.UCAR.EDU (Gerry Wiener) writes:
>In the following code an interrupt handler for the keyboard is
>replaced by one that increments a counter then chains to the original
>handler.  Question:  Why doesn't "count" get incremented correctly?
>Please mail me the replies.
>
>	Gerry Wiener	  Email:wiener at stout.ucar.edu
>
>------------------------------------------------------------------------
>
>#include <dos.h>
>#include <stdio.h>
>
>#define KEYBD  0x16
>
>void (interrupt far *oldkb)(void);
>void interrupt far newkb(void);
>int count;
>
>main()
>{
>  int c;
>
>  oldkb = _dos_getvect(KEYBD);
>
>  _dos_setvect(KEYBD, newkb);
> [...]
>  _dos_setvect(KEYBD, oldkb);
>}
>
>void interrupt far newkb(void)
>{
>  count++;
>  _chain_intr(oldkb);
>}

This is just an untested guess since I no longer have MSC to try
it on but try declaring count as a far int.

-- 
D'Arcy J.M. Cain (darcy at druid)     |   Thank goodness we don't get all 
D'Arcy Cain Consulting             |   the government we pay for.
West Hill, Ontario, Canada         |
(416) 281-6094                     |



More information about the Comp.lang.c mailing list