🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc
Article #42315

microsoft c isr question

#42315
From: Gerry Wiener
Date: Sun, 18 Feb 1990 00:21
40 lines
1190 bytes
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 <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);

  count = 0;
  while ((c = getchar()) != 'x')
    {
      printf("count is %d\n", count);
      putchar(c);
    }
  _dos_setvect(KEYBD, oldkb);
}

void interrupt far newkb(void)
{
  count++;
  _chain_intr(oldkb);
}
Technical Details
Message-ID: <WIENER.90Feb17172147@stout.stout.UCAR.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!handies.UCAR.EDU!wiener

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!handies.UCAR.EDU!wiener
From: wiener@stout.UCAR.EDU (Gerry Wiener)
Newsgroups: comp.sys.ibm.pc,comp.lang.c
Subject: microsoft c isr question
Message-ID: <WIENER.90Feb17172147@stout.stout.UCAR.EDU>
Date: 18 Feb 90 00:21:47 GMT
Sender: news@ncar.ucar.edu
Distribution: usa
Organization: NCAR
Lines: 41