home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / msdos / programm / 10855 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  3.6 KB

  1. Path: sparky!uunet!cs.utexas.edu!torn!news.ccs.queensu.ca!qucis.queensu.ca!ember!vicuna!frampton
  2. From: frampton@vicuna.ocunix.on.ca (Steve Frampton)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Interrupt function impossible to debug!
  5. Summary: Darn, I hate ISR programming!
  6. Keywords: dos borland bc
  7. Message-ID: <PeBouB1w165w@vicuna.ocunix.on.ca>
  8. Date: 23 Nov 92 03:55:12 GMT
  9. Reply-To: frampton@vicuna.ocunix.on.ca
  10. Followup-To: comp.os.msdos.programmer
  11. Organization: Vicuna Systems, Kingston, ON (613) 547-5066
  12. Lines: 79
  13. Content-Type: text/plain; charset=us-ascii
  14.  
  15. Hi everyone:
  16.  
  17. I am attempting to write an interrupt function for the INT 15h handler,
  18. so that I may intercept the 'SysRq' keypresses and do something useful
  19. with them.
  20.  
  21. Both "The NEW Peter Norton Programmer's Guide to The IBM PC & PS/2" as
  22. well as "PC System Programming For Developers" state that when this key
  23. is pressed, INT 15h is called with AH = 85h.  Therefore my function
  24. simply checks for this value, and if it is found then execute the
  25. "do_something_useful()" function.
  26.  
  27. However, for some reason it doesn't work!  I added a "beep" to the
  28. beginning of the handler just to see if it is getting executed, however
  29. as INT 15h is used for many different purposes the end result is a
  30. rapid plethora of beeps dragging the system to an almost halt (but I
  31. have *proved*, however, that the ISR is getting called).
  32.  
  33. So I don't know if my keyboard is not telling the BIOS I am pressing
  34. 'SysRq' (ALT-SysRq on an 101-key, SysRq on an 84-key), or if my BIOS
  35. is not telling the ISR, or my ISR is not reading the value correctly.
  36.  
  37. My attempts at debugging, both with the Debugger, as well as attempting
  38. to dump the value of AH to the printer have resulted in endless HANGS.
  39.  
  40. I have always stayed away from ISR's for this very reason (the complexity
  41. of debugging).  I hope, however, that someone with experience in these 
  42. matters can perhaps see something simple out of place, and I will see
  43. how rewarding ISR programming can be.
  44.  
  45. Here is as much of the code as required to illustrate my problems:
  46.  
  47. void interrupt (*old_sysreq_function)();
  48.  
  49. void interrupt sysreq_function(unsigned ax)
  50. /* This function is a replacement for the SYSREQ key interrupt. */
  51. {
  52.   if ((ax & 0xff00)==0x8500) {
  53.     disable();
  54.     reset_sysreq_function(); /* Don't want to be reentrant! */
  55.     enable();
  56.  
  57.     do_something_useful();  /* Execute the wonderful function. */
  58.  
  59.     disable();
  60.     set_sysreq_function();
  61.     enable();
  62.   }
  63.  
  64.   old_sysreq_function(); /* Call old function. */
  65. } /* end sysreq_function() */
  66.  
  67.  
  68. void set_sysreq_function(void)
  69. /* This function installs the sysreq_function() interrupt */
  70. /* function as the new INT 15h service 85h handler.       */
  71. {
  72.   old_sysreq_function=getvect(0x15); /* Get INT 15h handler. */
  73.   setvect(0x15,sysreq_function);     /* Install new INT 15h handler. */
  74. } /* end set_sysreq_function() */
  75.  
  76.  
  77. void reset_sysreq_function(void)
  78. /* This function resets the sysreq_function() back to normal. */
  79. {
  80.   setvect(0x15,old_sysreq_function); /* Restore old INT 15h handler. */
  81. } /* end reset_sysreq_function() */
  82.  
  83. That's it!
  84.  
  85. Please respond via e-mail to preserve bandwidth, I shall be glad to
  86. follow-up here with a summary.  Thanks in advance.
  87.  
  88. +-----------------------------------------------+--------------------+
  89. | Steve Frampton - frampton@vicuna.ocunix.on.ca | Steve Frampton     |
  90. | I collect postcards!  If you send me one from | 501-A Princess St. |
  91. | your area, I'll send one in return.  Send to >| Kingston, Ontario  |
  92. | (Don't forget both email and mailing address) | CANADA   K7L 1C3   |
  93. +-----------------------------------------------+--------------------+
  94.