Xref: utzoo comp.sys.ibm.pc:44725 comp.lang.c:26048 Path: utzoo!attcan!telly!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: microsoft c isr question Message-ID: <1990Feb18.174443.28133@druid.uucp> Date: 18 Feb 90 17:44:43 GMT References: Reply-To: darcy@druid.UUCP (D'Arcy J.M. Cain) Distribution: usa Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 44 In article wiener@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@stout.ucar.edu > >------------------------------------------------------------------------ > >#include >#include > >#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@druid) | Thank goodness we don't get all D'Arcy Cain Consulting | the government we pay for. West Hill, Ontario, Canada | (416) 281-6094 |