home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / msdos / programm / 9324 < prev    next >
Encoding:
Text File  |  1992-09-13  |  2.0 KB  |  64 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!caen!destroyer!ubc-cs!yogi
  3. From: yogi@cs.ubc.ca (Yossi Gil)
  4. Subject: Re: How does INT 16 know that INT 9 has executed?
  5. Message-ID: <1992Sep13.145200.19279@cs.ubc.ca>
  6. Sender: usenet@cs.ubc.ca (Usenet News)
  7. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  8. References: <1992Sep13.053140.12086@cs.ubc.ca>
  9. Date: Sun, 13 Sep 92 14:52:00 GMT
  10. Lines: 52
  11.  
  12. yogi@cs.ubc.ca (Yossi Gil) writes:
  13.  
  14. >Suppose you call int 16 with ah=0 and that there are no
  15. >keys in the keyboard queue. Int 16 codes then waits for
  16. >a keystroke to occur and return it.
  17.  
  18. >Q:  What is the communication mechanism? How does int 9 signal
  19. >to int 16 that a keystroke occured. 
  20.  
  21. >I did few experiments and as far as I can tell, int 16 doesn't loop
  22. >until head != tail for the keyboard queue. 
  23.  
  24. Checked again, disassembling the BIOS (AMI) and discovered that I 
  25. was wrong in my first conjecture. 
  26.  
  27. Basically, int 16, ah=0 waits for keystroke by doing the following:
  28.  
  29.     1. Disable interrupts.
  30.     2. Compare Head to Tail
  31.     3. Enable interrupts
  32.     4. If not equal goto 7. 
  33.     5. Call INT 15, AX=9002
  34.     6. Goto 1.    
  35.  
  36.     7. Read key.
  37.     8. If keyboard status changed, set the leds.
  38.     9. If enhanced key goto 1.
  39.     10. Return key.
  40.  
  41. I used this to patch INT 9 to add a new keystroke for ScrollLock. My
  42. code is:
  43.  
  44.     1. Record Scroll Lock shift status.
  45.     2. Call original int 9.
  46.     3. If key pending add it to the queue tail. 
  47.     4. If scroll lock status has not changed return. 
  48.     5. If keyboard buffer is not full, push "Scroll Lock" keystroke in
  49.     6. If full, toggle key pending status.
  50.     7. Return    
  51.  
  52. Using this patch, I can detect change in status of scroll lock without
  53. polling the keyboard status word.
  54.     
  55.  
  56.     
  57.  
  58.  
  59. --
  60. Joseph (Yossi) Gil                 {alberta,uw-beaver,uunet}!ubc-cs!yogi
  61. Dept. of Computer Science          yogi@cs.ubc.ca (cs.ubc.ca=137.82.8.5)
  62. 6356 Agricultural Road., Univ. of B.C.,             Tel: +1-604-822-8175
  63. Vancouver, British Columbia, V6T 1Z2, Canada.       Fax: +1-604-822-5485
  64.