home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / asm / wasm / key.asm < prev    next >
Assembly Source File  |  1987-05-05  |  4KB  |  152 lines

  1.  
  2.  Title 'Wolfware Assembler Sample Program', 'Key Reassignment'
  3.  
  4. ;=============================================================================
  5. ; Key Reassignment
  6. ;
  7. ; Reassign any string to any key via.  The ANSI.SYS device driver must be
  8. ; installed (see your DOS manual).  Once assembled, to reassign a key, type:
  9. ;
  10. ;   KEY <key code> <string>
  11. ;
  12. ; The parameters must be separated by a single space. Each parameter may
  13. ; consist of any combination of strings in double quotes and decimal ASCII
  14. ; codes, seperated by semicolons. The key to reset (first parameter) should be
  15. ; the key's character code (one or two bytes). The new assignment (second
  16. ; parameter) can be any combination of strings and ASCII values.
  17. ;
  18. ; Examples:
  19. ;
  20. ; KEY "g" "h"
  21. ;   Assign lower-case h to the lower-case g key.
  22. ;
  23. ; KEY 0;59 19
  24. ;   Assigns ^S to the F1 key. 0;59 is the key code for F1 and 19 is the ASCII
  25. ;   value for ^S. Makes F1 act like Ctl NumLock, i.e. to suspend the computer.
  26. ;
  27. ; KEY 0;68 "DIR";13
  28. ;   Assign DIR plus a carriage return to the F10 key.
  29. ;
  30. ; The extended codes for all applicable keys can be found in the BASIC manual
  31. ; right after the ASCII character table. Note that many application programs
  32. ; bypass the DOS keyboard routines, so the key reassingments will not work for
  33. ; them.
  34.  
  35.  Proc Far
  36.  
  37. ;--- print message
  38.  
  39.  Mov Dx, Offset Keymess ;message location
  40.  Call Str_Display       ;string display
  41.  
  42. ;--- number of characters
  43.  
  44.  Mov Cl, [Input]        ;number of characters
  45.  Sub Ch, Ch
  46.  Cmp Cl, 1              ;check if too few
  47.  Jb Keyerror            ;jump if so
  48.  
  49. ;--- print input and end CR
  50.  
  51.  Push Cx
  52.  Mov Si, Input + 2      ;start after space
  53.  Push Si
  54.  
  55.  Mov Dx, Offset Keymess2 ;message location
  56.  Call Str_Display       ;string display
  57.  
  58. Keyiloop
  59.  Lodsb                  ;load next byte
  60.  Call Display           ;display
  61.  Loop Keyiloop          ;loop CX times
  62.  
  63. ;--- move a line down
  64.  
  65.  Mov Al, 10             ;byte to display, LF
  66.  Call Display           ;display
  67.  
  68.  Pop Di
  69.  Pop Bx
  70.  
  71. ;--- scan for space
  72.  
  73.  Dec Bx                 ;do not count initial space
  74.  Mov Cx, Bx             ;number of characters to search
  75.  Mov Al,' '             ;look for space
  76.  
  77.  Repne
  78.  Scasb                  ;scan until found or no more
  79.  
  80. ;--- add semicolon
  81.  
  82.  Jne Keyerror           ;jump if not found
  83.  Mov Byte [Di-1], ';'   ;save semicolon to location
  84.  
  85. ;--- add start code
  86.  
  87.  Mov Ax, Ctl_Start      ;load starting control
  88.  Mov [Input], Ax        ;save
  89.  
  90. ;--- add end code
  91.  
  92.  Mov Ax, Ctl_End        ;load end control
  93.  Mov [Input+Bx+2], Ax   ;save
  94.  
  95. ;--- reset key
  96.  
  97.  Mov Dx, Input          ;control string location
  98.  Call Str_Display       ;string display
  99.  Jmps Exit
  100.  
  101. ;--- error in parameters
  102.  
  103. Keyerror
  104.  Mov Dx, Offset Keyemess ;error message location
  105.  Call Str_Display       ;string display
  106.  
  107. ;--- exit
  108.  
  109. Exit
  110.  Mov Ax, 4c00h          ;function
  111.  Int 21h                ;execute
  112.  
  113. ;================================================
  114. ; Display the character in AL to the screen.
  115.  
  116. Display Proc Near
  117.  Mov Dl, Al             ;byte to display
  118.  Mov Ah, 2              ;display byte function
  119.  Int 21h                ;execute
  120.  Ret
  121.  Endp                   ;Display
  122.  
  123. ;================================================
  124. ; Display the string at DX terminated by a dollar
  125. ; sign to the screen.
  126.  
  127. Str_Display Proc Near
  128.  Mov Ah, 9              ;string output function
  129.  Int 21h                ;execute
  130.  Ret
  131.  Endp                   ;Str_Display
  132.  
  133. ;================================================
  134. ; Data
  135.  
  136. Input Equ 80h           ;parameter location
  137.  
  138. Ctl_Start Label Word
  139.  Db 27,'['              ;start of reassignment sequence
  140. Ctl_End Label Word
  141.  Db 'p$'                ;end of reassignment sequence
  142.  
  143. Keymess Db 10,'Key Reassignment Version 1.10', 13, 10,'$'
  144. Keymess2 Db '--> $'
  145.  
  146. Keyemess Db 10,'Error in parameters: <key code> <output>', 13, 10
  147.  Db '  Each parameter may consist of any combination of', 13, 10
  148.  Db '  strings in double quotes and decimal ASCII codes,', 13, 10
  149.  Db '  seperated by semicolons.', 13, 10,'$'
  150.  Endp
  151.  
  152.