home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1989 / 03 / tricks / ckbd.asm next >
Encoding:
Assembly Source File  |  1988-12-15  |  4.9 KB  |  165 lines

  1. ;* ------------------------------------------------------- *
  2. ;*                      CKBD.ASM                           *
  3. ;*      Erweiterte Tastaturbelegung für das Editieren      *
  4. ;*                  von C-Programmen                       *
  5. ;*          (c) 1989 Olaf Stoyke und TOOLBOX               *
  6. ;* ------------------------------------------------------- *
  7. ;*               Assembler: MASM >= 4.0                    *
  8. ;*               masm ckbd.asm                             *
  9. ;*               link ckbd.obj                             *
  10. ;*               exe2bin ckbd.exe ckbd.com                 *
  11. ;* ------------------------------------------------------- *
  12. .8086
  13.  
  14. ; function request 09H
  15.  
  16. DISPLAY     macro  string
  17.             mov    dx,offset string
  18.             mov    ah,09H
  19.             int    21H
  20.             endm
  21.  
  22. ; function request 25H
  23.  
  24. SET_VECTOR  macro  interrupt,handler_start
  25.             mov    al,interrupt
  26.             mov    dx,offset handler_start
  27.             mov    ah,25H
  28.             int    21H
  29.             endm
  30.  
  31. ; function request 31H
  32.  
  33. KEEP_PROCESS  macro  return_code,last_byte
  34.             mov    al,return_code
  35.             mov    dx,offset last_byte
  36.             mov    cl,4
  37.             shr    dx,cl
  38.             inc    dx
  39.             mov    ah,31H
  40.             int    21H
  41.             endm
  42.  
  43. ; function request 35H
  44.  
  45. GET_VECTOR  macro  interrupt
  46.             mov    al,interrupt
  47.             mov    ah,35H
  48.             int    21H
  49.             endm
  50.  
  51. ; function request 4CH
  52.  
  53. END_PROCESS macro  return_code
  54.             mov    al,return_code
  55.             mov    ah,4CH
  56.             int    21H
  57.             endm
  58.  
  59. code  segment
  60.       assume  cs:code,ds:code,es:nothing,ss:nothing
  61.             org  100H
  62.  
  63. start:      jmp  begin
  64.  
  65. oldvector   equ  this dword
  66. ov_ofs      dw   ?
  67. ov_seg      dw   ?
  68. oldah       db   ?
  69.  
  70. xtable      equ  this word
  71.             dw   7D00h, 007Eh     ; [6 &]
  72.             dw   7E00h, 007Ch     ; [7 /]
  73.             dw   7F00h, 007Bh     ; [8 (]
  74.             dw   8000h, 007Dh     ; [9 )]
  75.             dw   -1, -1
  76.  
  77. ;
  78. ; Der neue Interrupt-Handler als PROC FAR
  79. ;
  80.  
  81. isrhandler  proc  far
  82.  
  83.             jmp short int16
  84.  
  85. id          db  "OS"             ; program id string
  86.  
  87. int16:      sti                  ; interrupts erlauben
  88.             push  bx             ; sichere bx
  89.             push  si             ; sichere si
  90.             push  ds             ; sichere ds
  91.  
  92.             push  cs             ; ds = cs
  93.             pop  ds
  94.             mov  oldah,ah        ; funktionscode sichern
  95.             pushf                ; int 16h simulieren
  96.             call  cs:[oldvector]
  97.             pushf                ; int 16h ausgabe sichern
  98.             cmp  oldah,2         ; nur shift codes lesen ?
  99.             jz      exit         ; ja -> exit
  100.             mov  si,offset xtable
  101.             mov  bx,ax
  102.             cld
  103.  
  104. l1:         lodsw                ; tabellenelement laden
  105.             cmp  ax,-1           ; tabellenende gelesen ?
  106.             jz  l3               ; ja -> exit
  107.             cmp  ax,bx           ; gesuchter eintrag ?
  108.             jz  l2               ; ja -> exit
  109.             inc  si              ; si += 2
  110.             inc  si
  111.             jmp  l1              ; und wiederholen
  112.  
  113. l2:         lodsw                ; neuen Tastencode laden
  114.             jmp  exit            ; und ende
  115. l3:         mov  ax,bx           ; ax restaurieren
  116.  
  117. exit:       popf                 ; int 16h-flags zurückholen
  118.             pop  ds              ; ds zurückholen
  119.             pop     si           ; si zurückholen
  120.             pop  bx              ; bx zurückholen
  121.             ret  2               ; isr ende mit alten flags
  122.  
  123. isrhandler  endp
  124.  
  125. ;
  126. ; Der folgende Code kann nach der Initialisierung
  127. ; überschrieben werden
  128. ;
  129.  
  130. transient  equ  this byte
  131.  
  132. intro       db  10, 13
  133.             db  "CKBD Version 1.01", 10, 13
  134.             db  "Copyright (c) 1989 Olaf Stoyke & TOOLBOX"
  135.             db  10, 13, "$"
  136.  
  137. okmessage   db  "Program installed.", 10, 13
  138.             db  "(German keyboard)", 10, 13
  139.             db  "[Alt][6 &] = ~ (126)", 10, 13
  140.             db  "[Alt][7 /] = | (124)", 10, 13
  141.             db  "[Alt][8 (] = { (123)", 10, 13
  142.             db  "[Alt][9 )] = } (125)", 10, 13, "$"
  143.  
  144. errmessage  db  7
  145.             db  "Program is already installed.", 10, 13, "$"
  146.  
  147. begin:      DISPLAY intro
  148.             GET_VECTOR 16h               ; get int vector
  149.             cmp  word ptr es:[bx+2],"SO"
  150.                              ; program bereits installiert ?
  151.             jnz  install
  152.             DISPLAY errmessage           ; ja -> exit
  153.             END_PROCESS 0
  154.  
  155. install:    mov  ov_ofs, bx
  156.             mov  ov_seg, es
  157.             SET_VECTOR 16h, isrhandler
  158.             DISPLAY okmessage
  159. return:     KEEP_PROCESS 0, transient
  160.  
  161. code   ends
  162.        end  start
  163. ;* ------------------------------------------------------- *
  164. ;*                   Ende von CKBD.ASM                     *
  165.