home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / keyboard / swapkey.asm < prev    next >
Assembly Source File  |  1994-03-04  |  5KB  |  119 lines

  1. ;==============================================================;
  2. ;                                                              ;
  3. ;  Author       :  Roy Fan                                     ;
  4. ;                  fan@uci-750a                                ;
  5. ;  Program Name :  SwapKey.ASM                                 ;
  6. ;  Date Written :  August 10, 1984  @ 09:15                    ;
  7. ;  Last Revision:  August 26, 1984  @ 09:55                    ;
  8. ;  Documentation:  August 26, 1984  @ 09:55                    ;
  9. ;                                                              ;
  10. ;    This program SwapKey will swap two keys on the IBM ill-   ;
  11. ;  designed keyboard:  left shift key and back slash key.  It  ;
  12. ;  occupies only 80 bytes under DOS 1.x or 144 bytes under     ;
  13. ;  DOS 2.x once installed.                                     ;
  14. ;                                                              ;
  15. ;  Note:  This version of ROM is released on 04/24/81          ;
  16. ;                                                              ;
  17. ;  Caution:                                                    ;
  18. ;                                                              ;
  19. ;    1.  Since this program makes direct call to specific      ;
  20. ;        location in ROM, it might not work with other         ;
  21. ;        versions of ROM or other IBM compatibles.             ;
  22. ;    2.  For the same reason given above, this program will    ;
  23. ;        not work with other keyboard utilities, such as,      ;
  24. ;        ProKey, ScrolLk, SmartKey, etc.                       ;
  25. ;                                                              ;
  26. ;==============================================================;
  27.  
  28. ;--------
  29. ; Equates
  30. ;--------
  31.  
  32. DATA          EQU    40H           ; ROM BIOS Data Area
  33. KB_DATA       EQU    60H           ; 8255 Port A
  34. Shift_Key     EQU    02AH          ; scan code for left shift key
  35. Slash_Key     EQU    02BH          ; scan code for back slash key
  36. DOS_1_x       EQU    16H           ; start address of codes under DOS 1.x
  37. DOS_2_x       EQU    5CH           ; start address of codes under DOS 2.x
  38. Start_Code    EQU    DOS_2_x       ; start address of codes
  39.  
  40. ;------------------
  41. ; Interrupt Vectors
  42. ;------------------
  43.  
  44. Vector        SEGMENT AT 0
  45.               ORG    24H           ; Keyboard interrupt (type 9)
  46. Keyboard_Int  DD     ?
  47. Vector        ENDS
  48.  
  49. ;------
  50. ; Codes
  51. ;------
  52.  
  53. Swap_Shift    SEGMENT
  54.               ASSUME  CS:Swap_Shift, DS:Vector
  55.               ORG     100H
  56.  
  57. Start:        JMP    SHORT Init_Vect
  58.  
  59. Keyboard:
  60.               STI                  ;
  61.               PUSH   AX            ;
  62.               PUSH   BX            ;
  63.               PUSH   CX            ;
  64.               PUSH   DX            ;
  65.               PUSH   SI            ;
  66.               PUSH   DI            ; Duplicate the codes in ROM at location
  67.               PUSH   DS            ; F000:E987 .. F000:E996
  68.               PUSH   ES            ;
  69.               CLD                  ;
  70.               MOV    AX,DATA       ;
  71.               MOV    DS,AX         ;
  72.               IN     AL,KB_DATA    ;
  73.               MOV    AH,AL         ; save the scan code in AH
  74.               AND    AH,80H        ; save only the break bit in AH
  75.               AND    AL,7FH        ; turn off the break bit  in AL
  76.               CMP    AL,Shift_Key  ; is it the left shift key
  77.               JE     Shift         ;    Yes
  78.               CMP    AL,Slash_Key  ; is it the back slash key
  79.               JE     Slash         ;    Yes
  80. Old_Keyboard:
  81.               OR     AL,AH         ; restore the break bit
  82.               DB     0EAH          ;
  83.               DW     0E998H        ; do a long jump to F000:E998
  84.               DW     0F000H        ;
  85. Shift:        MOV    AL,Slash_Key  ; change the back slash key to shift key
  86.               JMP    Old_Keyboard  ;   resume codes in ROM
  87. Slash:        MOV    AL,Shift_Key  ; change the shift key to back slash key
  88.               JMP    Old_Keyboard  ;   resume codes in ROM
  89.  
  90. Init_Vect:
  91.               CLD
  92.               MOV    SI,OFFSET Keyboard
  93.               MOV    DI,Start_Code
  94.               MOV    CX,OFFSET Init_Vect - OFFSET Keyboard
  95.               REP    MOVSB
  96.  
  97. ; copy the codes to location Start_Code (16H)
  98.  
  99.               MOV    DX,DI         ; save last location of the codes in DX
  100.  
  101.               XOR    AX,AX
  102.               MOV    ES,AX
  103.               MOV    AX,Start_Code
  104.               MOV    DI,OFFSET Keyboard_Int
  105.               CLI
  106.               STOSW
  107.               MOV    AX,CS
  108.               STOSW
  109.               STI
  110.  
  111. ; point the keybaord interrupt to our own codes
  112.  
  113.               INT    27H           ; make our codes resident
  114.  
  115. Swap_Shift    ENDS
  116.  
  117. END           Start
  118.  
  119.