home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / at / swpkeyat.arc / SWAPKEY.ASM next >
Encoding:
Assembly Source File  |  1989-01-19  |  2.2 KB  |  95 lines

  1. ;    name...
  2. ;        swapkey
  3. ;
  4. ;    function...
  5. ;
  6. ;    Swap the escape and tilde keys using the "keyboard intercept"
  7. ;    ROM BIOS feature: INT 15 with AH=4fH.
  8. ;
  9. ;    This interrupt feature is implemented on recent AT class machines, 
  10. ;    including at least these:
  11. ;        AT (models 319/339 only), convertable, and PS/2
  12. ;        clones with the Award BIOS
  13. ;
  14. ;    on entrance to this interrupt,
  15. ;        AH = 4fH
  16. ;        AL = scan code
  17. ;        carry flag is set
  18. ;
  19. ;    on return from the interrupt,
  20. ;        AL = scan code (possibly changed)
  21. ;        carry flag cleared if scan code is to be ignored
  22. ;
  23. ;    An AT with a BIOS module dated 01/04/84 does not have the "keyboard intercept"
  24. ;    feature.  For that machine, use the companion program SWPKEYAT.
  25. ;
  26. ;    Documentation courtesy of: Thom Hogan, "The Programmer's PC Sourcebook"
  27. ;
  28. ;    Author: James R. Van Zandt (jrv@mitre-bedford.arpa)
  29. ;
  30. VECTORS        SEGMENT    AT 0H
  31.     ORG    15H*4
  32. INT_VECTOR    LABEL    DWORD
  33. VECTORS        ENDS
  34.  
  35.  
  36. CODE_SEG    SEGMENT
  37.     ASSUME    CS:CODE_SEG
  38.     ORG    100H
  39. BEGIN:    JMP    INIT_VECTORS        ;Initialize vectors and attach to DOS
  40. ROM_INT    DD
  41.  
  42.  
  43. INTERCEPT_INT    PROC    NEAR
  44.     ASSUME    DS:NOTHING
  45.     CMP    AH,4FH
  46.     JZ    SWP_1
  47.  
  48. CONTINUE:
  49.     JMP    ROM_INT            ; jump to former routine
  50.  
  51. SWP_1:
  52.     CMP    AL,001H            ; ESC scan code?
  53.     JNZ    SWP_2
  54.  
  55.     MOV    AL,029H            ; substitute tilde scan code
  56.     JMP    CONTINUE
  57.  
  58. SWP_2:
  59.     CMP    AL,029H            ; tilde scan code?
  60.     JNZ    CONTINUE
  61.  
  62.     MOV    AL,001H            ; substitute ESC key scan code
  63.     JMP    CONTINUE
  64.  
  65.  
  66. INTERCEPT_INT ENDP
  67.  
  68.  
  69. ;-----------------------------------------------------------------;
  70. ;This procedure initializes the interrupt vectors.          ;
  71. ;-----------------------------------------------------------------;
  72. INIT_VECTORS    PROC    NEAR
  73.     ASSUME    DS:VECTORS
  74.     PUSH    DS            ;Save old Data Segment
  75.     MOV    AX,VECTORS        ;Set up the data segment for vectors
  76.     MOV    DS,AX
  77.     CLI                ;Don't allow interrupts
  78.  
  79.     MOV    AX,word ptr INT_VECTOR    ;Save addresses of BIOS routines
  80.     MOV    word ptr ROM_INT,AX
  81.     MOV    AX,word ptr INT_VECTOR[2]
  82.     MOV    word ptr ROM_INT[2],AX
  83.                     ;Set up new KEYBOARD_INT vector
  84.     MOV    word ptr INT_VECTOR,OFFSET INTERCEPT_INT
  85.     MOV    word ptr INT_VECTOR[2],CS
  86.     STI                ;Allow interrupts again
  87.  
  88.     MOV    DX,OFFSET INIT_VECTORS    ;End of resident portions
  89.     INT    27H            ;Terminate but stay resident
  90. INIT_VECTORS    ENDP
  91.  
  92. CODE_SEG    ENDS
  93.  
  94.     END    BEGIN
  95.