home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / asm / 80x0393 / keyb.asm < prev    next >
Encoding:
Assembly Source File  |  1993-07-16  |  4.5 KB  |  109 lines

  1. (7042)  Wed 14 Jul 93 10:41p
  2. By: Emil Gilliam
  3. To: Graham Allen
  4. Re: Re: assembler
  5. St:                                                                       <5850
  6. ---------------------------------------------------------------------------
  7. @MSGID: 1:147/3006 2c44cd4f
  8. @PID: TeleMail 1.51
  9.  -=> Quoting Graham Allen to Andrew Gayton <=-
  10.  
  11.  GA> Is there any way to solve this WITHOUT having to redirect int9 to
  12.  GA> a subroutine ?
  13.  
  14.  AG> Give this a bash :
  15.  AG>                     in    al,  61h
  16.  AG>                     mov   ah,  al
  17.  AG>                     or    al,  80h
  18.  AG>                     out   61h, al
  19.  AG>                     xchg  ah,  al
  20.  AG>                     out   61h, al
  21.  AG>                     mov   al,  20h    ; left of these two lines
  22.  AG>                     out   20h, al
  23.  
  24.  GA> Sorry...I tried it, it doesn't work... :(
  25.  
  26.  GA> Reseting the interrupt controller wouldn't make any difference unless
  27.  GA> I had redirected Int 9h I think.
  28.  
  29.  GA> Using Int16h works but it is way too slow.
  30.  
  31.  GA> thanx anyway
  32.  
  33.    Since this is the first message in this thread I have read, I'm not
  34. sure, but I would guess that you're trying to temporarily disable the
  35. keyboard.  The code given up there should work.  I think what you're doing
  36. wrong is: You don't just execute the code like that, that's supposed to be
  37. an actual interrupt 9 handler!  (Of course, you need to PUSH AX, and POP AX
  38. and IRET at the end.)
  39.  
  40.    However, this is the easiest way to completely disable the keyboard (by
  41. messing with the interrupt controller):
  42.  
  43. in al,21h
  44. or al,00000010b
  45. out 21h,al
  46.  
  47.    This is not an interrupt handler; you just execute those three lines
  48. just like that in your program and it will disable the keyboard!  This is a
  49. lot easier than any other method because you don't have to install your own
  50. interrupt handler or anything!  How it works is: I/O port 21h controls
  51. which IRQs (from 0 to 7 corresponding to interrupt vectors 8h through 0Fh)
  52. are masked.  The code above gets its value, masks IRQ1 (interrupt 9, the
  53. keyboard), and writes it back!  You could also do it by using the processor
  54. instruction CLI to disable interrupts but then no other interrupts (clock
  55. interrupts, etc.) can get through.
  56.  
  57.    When you want to enable the keyboard again, just do these three lines:
  58.  
  59. in al,21h
  60. and al,11111101b
  61. out 21h,al
  62.  
  63.    This sets the bit back to 0 meaning that interrupt 9 can happen again!
  64.  
  65.    I have to admit that there is a problem with this method: If keys are
  66. pressed while the keyboard is disabled, the keyboard controller might keep
  67. a few keys meaning that when the keys are pressed when the keyboard is re-
  68. enabled, the keyboard controller might return the scan codes of the keys
  69. pressed while the keyboard was disabled!
  70.  
  71.    So perhaps the method given by Andrew Gayton is better.  The complete
  72. interrupt 9 handler (be sure to set the old interrupt 9 handler back when
  73. you want to re-enable the keyboard) will look like this...  (It's slightly
  74. modified from the code that Andrew Gayton gave.  I can tell that came from
  75. the IBM ROM BIOS code because of the fact that an unnecessary XCHG is used
  76. when MOV could have been used although it doesn't really matter since the
  77. code size is the same)...
  78.  
  79. push    ax                      ;Save AX
  80.  
  81. in      al,61h                  ;Set the high bit of port 61h to 1 and then
  82. mov     ah,al                   ; back to 0.  This will tell the keyboard
  83. or      al,80h                  ; controller that the scan code has been
  84. out     61h,al                  ; read (when it really hasn't) so that
  85. mov     ah,al                   ; the keyboard controller will take the key
  86. out     61h,al                  ; off of its buffer.
  87.  
  88. mov     al,20h                  ;Tell the interrupt controller that we've
  89. out     20h,al                  ; reached the end of the interrupt 9
  90.                                 ; handler.  That way, the interrupt
  91.                                 ; controller will allow further interrupt
  92.                                 ; 9's to occur.
  93.  
  94. pop     ax                      ;Restore AX
  95. iret                            ;Interrupt return
  96.  
  97.    Hope this helps!  (Of course, I'm not sure whether or not you were
  98. trying to disable the keyboard in the first place, but I hope this helps
  99. anyway...)
  100.  
  101.                                                            Emil Gilliam
  102.  
  103.  
  104. ... Life after death?  Is it like terminate and stay resident?
  105. --- GEcho 1.00
  106.  * Origin: Doesn't run? Execute the data segment (405)6725644 (1:147/3006.0)
  107.  
  108. @PATH: 147/3006 19/150 147/20 7 209/209 396/1 13/13 260/1
  109.