home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / MISC_ASM.ZIP / SETKEY.ASM < prev    next >
Encoding:
Assembly Source File  |  1985-07-07  |  3.4 KB  |  83 lines

  1. ;name: setkey,asm (setkey.com) by kevin m crenshaw
  2. cseg    segment
  3. assume  cs:cseg,ds:cseg
  4. org     100h
  5. ;------ get typematic rate: a to z, [, \, ], ^, _, or '
  6. start:  mov    si,81h          ;point to command line
  7.         xor    bx,bx           ;set default
  8. letter: lodsb                  ;get first non-space char
  9.         cmp    al," "
  10.         je     letter
  11.         jb     send            ;end of line, use default
  12.         dec    al
  13.         and    al,0dfh         ;upper case
  14.         sub    al,"@"          ;valid letter or symbol?
  15.         jnb    lettr1          ;  maybe
  16.         dec    si              ;  no, might be a digit
  17.         jmp    short digit
  18. lettr1: cmp    al,31           ;valid letter or symbol
  19.         ja     error2          ;  no, error
  20.         xchg   al,bl           ;  yes, save as typematic rate
  21. ;------ get delay value: 1 to 4
  22. digit:  lodsb                  ;get next non-space character
  23.         cmp    al," "
  24.         je     digit
  25.         jb     send            ;end of line, use what we have
  26.         sub    al,"1"          ;valid digit?
  27.         jb     error2          ;  no, error
  28.         cmp    al,3            ;valid digit
  29.         ja     error2          ;  no, error
  30.         mov    cl,5            ;  yes, save as delay value
  31.         shl    al,cl
  32.         or     bl,al
  33. ;------ send values to keyboard
  34. send:   mov    al,0f3h         ;set typematic/delay
  35.         call   xmit            ;command accepted?
  36.         jcxz   error1          ;  no, error
  37.         xchg   al,bl           ;send typematic/delay values
  38.         call   xmit            ;values accepted?
  39.         jcxz   error1          ;  no, error
  40.         int    20h             ;return to dos
  41. ;------ bad input
  42. error1: mov    dx,offset error1$       ;hardware error
  43.         jmp    short error
  44. error2: mov    dx,offset error2$       ;bad input error
  45. error:  mov    ah,9                    ;print message
  46.         int    21h
  47.         int    20h
  48. error1$ db     "Hardware error",13,10,"$"
  49. error2$ db     "Valid parameters are A-Z, then 1-4",13,10,"$"
  50. ;xmit - send data to keyboard
  51. ;in:    al     - data to send
  52. ;out:   ax     - destroyed
  53. ;       cx     - zero if error, nonzero otherwise
  54. xmit    proc   near
  55.         cli                    ;interrupts off
  56.         xchg   al,ah           ;save command
  57.         xor    cx,cx
  58. xmtwt1: in     al,64h
  59.         test   al,2            ;is data waiting for cntrlt?
  60.         loopnz xmtwt1          ;  yes, wait
  61.         jcxz   xmtret          ;error, cntrlr not reading data
  62.         xchg   al,ah           ;get command back
  63.         out    60h,al          ;send to keyboard
  64.         xor    cx,cx
  65. xmtwt2: in     al,64h
  66.         test   al,2            ;has controller read data yet?
  67.         loopnz xmtwt2          ;  no wait
  68.         jcxz   xmtret          ;error, cntrlr not reading data
  69.         xor    cx,cx
  70. xmtwt3: in     al,64h
  71.         test   al,1            ;did keyboard send ACK yet?
  72.         loopz  xmtwt3          ;  no, wait for it
  73.         jcxz   xmtret          ;  error, no response
  74.         in     al,60h          ;get response
  75.         cmp    al,0fah         ;was it ACK?
  76.         je     xmtret          ;  yes
  77.         xor    cx,cx           ;  no, error
  78. xmtret: sti                    ;interrupts back on
  79.         ret
  80. xmit    endp
  81. cseg    ends
  82.         end    start
  83.