TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: SYLVAIN LAUZON
from: DENIS BOYLES
date: 1997-03-20 22:57:00
subject: Interrupts

Here's a quick TSR that toggles the Scroll-Lock LED on/off by using the
timer ticker. Because the ticker gets called 18.2/second, the appearance is
given of a background program. Really, the computer interrupts whatever is
happening every 18.2 times and calls the TSR. The TSR inturn when done jumps
to the previous handler in the chain. This allows other programs that use the
ticker to have access to it. Once the chain is completed, the interrupted
program resumes, until another interrupt.
;----------------------------------------------------------------------------
;[BLINKY.ASM] - Public Domain by Denis Boyles
;             ! Arrowsoft Assembler v1.00D (MASM v3.0)
;             ? TSR that blinks ScrollLock LED on/off approx. every second
TIMEOUT     EQU 18                     ;blink timeout, 18/18.2 = approx 1s
LED         EQU 16                     ;Scroll-Lock LED bit
DOS         EQU 21h                    ;DOS services interrupt
PRG SEGMENT
    ASSUME CS:PRG,DS:PRG
    ORG 0100h
MAIN:
    jmp     INIT                       ;jump to install routine
OldTck      dd ?                       ;original vector for timer ticker
count       db TIMEOUT                 ;count down counter
NewTck:                                ;our timer ticker interrupt
    push    AX                          ;save AX to stack
    push    ES                          ;save ES to stack
    mov     AL,CS:[count]               ;AL = current tick count
    or      AL,AL                       ;test for zero?
    jz      NT0                         ;if zero then time to toggle LED
    dec     CS:[count]                  ;otherwise, decrement countdown
    jmp     NT1                         ;jump over toggle code to exit
NT0:                                   ;toggle LED and reset counter
    mov     CS:[count],TIMEOUT          ;set counter back to TIMEOUT value
    xor     AX,AX                       ;zero out AX and use it to
    mov     ES,AX                       ;set ES to access BIOS data
    xor     byte ptr ES:[417h],LED      ;toggle LED via BIOS keyboard byte
NT1:                                   ;exit interrupt handler
    pop     ES                          ;restore ES
    pop     AX                          ;restore AX
    jmp     CS:[OldTck]                 ;chain to previous int via jump
INIT:                                  ;TSR initialization routine
    mov     AX,351Ch                    ;DOS get vector for 1Ch
    int     DOS                         ;call DOS to get ticker vector
    mov     word ptr [OldTck][2],ES     ;save vector segment into memory
    mov     word ptr [OldTck][0],BX     ;save vector offset into memory
    mov     AX,251Ch                    ;DOS set vector for 1Ch
    mov     DX,offset NewTck            ;DS:DX -> new handler
    int     DOS                         ;call DOS to set new handler
    mov     CL,04h                      ;shift count = 4
    mov     DX,offset INIT              ;all code upto INIT is kept resident
    shr     DX,CL                       ;convert to paragraphs via shifting
    inc     DX                          ;plus one more paragraph for safety
    mov     AX,3100h                    ;DOS TSR program with code (0)
    int     DOS                         ;call DOS to TSR program
PRG ENDS
    END MAIN
;----------------------------------------------------------------------------
Cheers,
  Denis Boyles
 * OLX 2.1 TD * Chicken heads are the chief food of captive alligators.
--- Maximus/2 3.01
---------------
* Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.