home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_31.arc / SPEEDSET.ASM < prev    next >
Assembly Source File  |  1979-12-31  |  3KB  |  100 lines

  1. title SpeedSet
  2.  
  3. fast    equ    43h    ; scan code for f9 key
  4. slow    equ    44h    ; scan code for f10 key
  5. kb_data    equ    60h    ; PIO port A - contains scan code
  6. kb_ctl    equ    61h    ; PIO port B - contains unused bit
  7.                         ; and keyboard acknowledge bit
  8.  
  9. code    segment         ; everything goes in code segment
  10.     org    100h
  11.  
  12.     assume    cs:code        
  13.  
  14. DOS_entry    label    far     
  15.     jmp    setup
  16.  
  17. old_int dd    ?       ; address of interrupt 9 code in ROM     
  18.  
  19. new_int    proc    far     ; beginning of our interrupt handler
  20.         sti             ; INT 9 turns off interrupts, reenable
  21.     push    ax      ; save registers
  22.     push    bx
  23.     push    dx
  24.     mov    ah,2    ; tell INT 16 to return kb_flag
  25.     int    16h            ; get kb_flag
  26.     and    al,00001000b    ; mask bits except alt status
  27.     cmp    al,00001000b    ; check alt key status
  28.     jne    short no_act    ; don't act if alt not pressed
  29.     in    al,kb_data    ; get scan code
  30.         cmp     al,fast         ; is it the f9 key?
  31.         je      short faster    ; speed up if it is
  32.         cmp     al,slow         ; is it the f10 key?
  33.     je    short slower    ; slow down if it is
  34.  
  35. no_act:    pop    dx              ; restore registers
  36.     pop    bx
  37.     pop    ax
  38.     jmp    old_int         ; let ROM code do it's thing
  39.  
  40. done:    in    al,kb_ctl    ; get keyboard status
  41.     or    al,10000000b    ; set keyboard acknowledge bit
  42.     out    kb_ctl,al    ; write it back to port 
  43.     pop    dx              ; restore registers
  44.     pop    bx
  45.     pop    ax
  46.     jmp    old_int         ; jump to ROM code to finish
  47.  
  48. faster: in    al,kb_ctl       ; get value from PIO port B
  49.     and    al,11110111b    ; reset unused bit  
  50.     out    kb_ctl,al       ; write it back to port B
  51.         jmp    short done      ; finish
  52.  
  53. slower: in    al,kb_ctl       ; get value from PIO port B
  54.     or    al,00001000b    ; set unused bit
  55.     out    kb_ctl,al       ; write it back to port B
  56.         jmp    short done      ; finish
  57.  
  58. new_int    endp                    ; end of our interrupt 
  59.  
  60. end_res_code:
  61.  
  62. sign_on    db    13,10,18 dup (32),201,42 dup (205),187,13,10
  63.     db    18 dup (32),186,'        SPEED SWITCH NOW '
  64.         db      'INSTALLED        ',186,13,10,18 dup (32)
  65.         db      186,' Alt F9 ',26,' Slow     ',1,'  '
  66.     db    2,'    Alt F10 ',26,' Fast ',186,13,10
  67.     db    18 dup (32),200,42 dup (205),188,13,10,'$'
  68.  
  69. err_msg    db    13,10,'SPEED SWITCH ALREADY INSTALLED'
  70.         db      13,10,'$'
  71.  
  72.     assume    ds:code
  73.  
  74. setup   proc    near            ; install our routine
  75.                                 ; as resident code 
  76.     mov    ax,3509h        ; get address of interrupt 9
  77.     int    21h
  78.     mov    ax,es           ; segment is returned in es
  79.     cmp    ax,0f000h       ; is this address in ROM?
  80.     je    short install   ; if so, install our code
  81.     mov    dx,offset err_msg       ; if not, write msg
  82.     mov    ah,9            ; that our code is already 
  83.     int    21h             ; installed
  84.     int    20h             ; exit to DOS
  85. install:mov    dx,offset sign_on       ; write sign on msg
  86.     mov    ah,9
  87.     int    21h
  88.     mov    word ptr old_int,bx     ; save ROM address
  89.     mov    word ptr old_int+2,es   ; of interrupt 9
  90.     mov    dx,offset new_int       ; set up new
  91.     mov    ax,2509h                ; interrupt vector
  92.     int    21h
  93.     mov    dx,offset end_res_code  ; make our code
  94.     int    27h                     ; resident
  95.  
  96. setup   endp
  97. code    ends
  98.     end    DOS_entry
  99.  
  100.