home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / keyboard / keyutils.arc / RESETKEY.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-09-05  |  4.0 KB  |  93 lines

  1. comment |
  2.  
  3.        Program name:  Resetkey.asm
  4.  
  5.        Author:  Terry N. Bezue
  6.  
  7.        Date:  10/17/87
  8.  
  9.        Purpose:  Reset function keys 1-40 to original status
  10.  
  11.        Requirements:  ANSI.SYS must be installed to work correctly
  12.  
  13.        Recompile instructions:
  14.                masm resetkey;
  15.                link resetkey;
  16.                exe2bin resetkey resetkey.com
  17.                del resetkey.exe
  18.  
  19.        |
  20. ;      macro to print data at address
  21. print  macro   address
  22.        lea     dx,address
  23.        mov     ah,9
  24.        int     21h
  25.        endm
  26. code   segment
  27.        assume cs:code,ds:code,ss:code,es:code
  28.                org     80h
  29. nbytes         label   byte
  30.                org     82h
  31. input          label   byte
  32.                org     100h
  33. resetkey:      jmp     short start
  34. escape         db      27,'[$'
  35. key            db      '0;',0,0,0,'$'
  36. colon          db      ';$'
  37. endseq         db      'p$'
  38. errmsg         db      7,'Invalid parameters in input$'
  39. start:         xor     dh,dh           ; zero dh
  40.                mov     bx,10           ; convert to key code
  41.                mov     cl,nbytes       ; Get # of bytes entered
  42.                xor     ch,ch           ; zero ch
  43.                dec     cx              ; skip first blank char
  44.                cmp     cl,0            ; more chars entered
  45.                jg      parse           ; yes, process line
  46.                jmp     error           ; no, error
  47. parse:         lea     di,input        ; get address of input
  48.                mov     al,' '          ; find first
  49.                repe    scasb           ;   non blank char
  50.                jz      error           ; if all blank, error
  51.                dec     di              ; adjust si
  52.                inc     cx              ;  ... and cx
  53.                xor     ax,ax           ; zero ax
  54. get_key:       mov     dl,[di]         ; get char
  55.                cmp     dl,' '          ; is it a blank
  56.                jz      ck_key          ; if so, check for vadility
  57.                cmp     dl,'0'          ; is it zero
  58.                jb      error           ; if less, error
  59.                cmp     dl,'9'          ; is it a nine
  60.                ja      error           ; if greater, error
  61.                sub     dl,'0'          ; make hex
  62.                mul     bl              ; mul old number by 10
  63.                add     ax,dx           ; add next digit
  64.                inc     di              ; point to next char
  65.                loop    get_key         ; do next digit
  66. ck_key:        cmp     ax,0            ; key must be between 1 and 40
  67.                jle     error           ; if less than 1, error
  68.                cmp     ax,10           ; was it a 10
  69.                jle     adj_main        ; if so, adjust for main fkeys
  70.                cmp     ax,40           ; greater than 40
  71.                jg      error           ; if so, error
  72.                add     ax,15           ;   adjust for extended keys
  73. adj_main:      add     ax,58           ; adjust fo main fkeys
  74.                lea     si,key+4        ; get key address
  75.                push    cx              ; save remaining byte count
  76.                mov     cx,3            ; will be at 3 digits in key
  77. put_digit:     xor     dx,dx           ; zero in dx
  78.                div     bx              ; divide by ten
  79.                add     dl,'0'          ; convert to ascii
  80.                mov     [si],dl         ; store it
  81.                dec     si              ; next digit
  82.                loop    put_digit       ; do next digit
  83.                print   escape          ; print setup part
  84.                print   key             ; print converted key number
  85.                print   colon           ; print the colon
  86.                print   key             ; print converted key number
  87.                print   endseq          ; print last part
  88.                jmp     short done      ; we're done
  89. error:         print   errmsg           ; print error message
  90. done:          int     20h             ; terminate
  91. code           ends
  92.                end     resetkey
  93.