Note: This is the June 17, 2006 capture of http://bentong.topcities.com/comp/progs/asm/tsr.htm from the Wayback Machine. This was uploaded to the reloaded ISLESV.NET on June 22, 2023.
; TSR.SHL: Shell for TSR programs, uses INT 27H. ; ; This file Copyright (C) 2004-2005 by Vincent "Bentong" S. Isles ; http://bentong.topcities.com ; bentong_isles@yahoo.com .MODEL SMALL ; Put the interrupt number you want to hook here... HOOKED_INT EQU 9 .CODE ORG 100H ENTRY: JMP LOAD_PROG OLD_INT LABEL WORD ; so we can treat old_int_addr OLD_INT_ADDR DD ? ; as word and double word PROG PROC PUSH AX ; save all registers PUSH BX ; there's PUSHA and POPA PUSH CX ; for higher processors PUSH DX PUSH DI PUSH SI PUSH DS PUSH ES PUSHF CALL OLD_INT_ADDR ; call old interrupt first ; prog here ; prog here EXIT: POP ES POP DS POP SI POP DI POP DX POP CX POP BX POP AX IRET ; remember, this an interrupt PROG ENDP LOAD_PROG PROC ; sole purpose: set up TSR MOV AH,35H ; get old vector into ES:BX MOV AL,HOOKED_INT ; number of hooked interrupt INT 21H MOV OLD_INT,BX ; store old interrupt vector MOV OLD_INT[2],ES MOV AH,25H ; set new interrupt vector LEA DX,PROG INT 21H EXIT_LOAD: MOV DX,OFFSET LOAD_PROG ; last address we want to INT 27H ; keep LOAD_PROG ENDP END ENTRY