; Sample TSR Code org 0x100 ; Skip first 0x100 bytes of .COM file JMP Install ; ----- Variables ----- OldR DD ? ; Original function MyIntN: ; ----- Call existing interrupt routine ----- Pushf ; Push flags (for CALL to old procedure) Call CS:OldR ; (CS override ensures far call) ; ----- Body of new ISR function ----- ; your code here .. IRET ; Restore flags and finish interrupt Install: ; Set DS=CS for tiny .COM programs MOV AX,CS MOV DS,AX ; ----- Store original vector in OldR ----- MOV AL, N ; N=vector number MOV AH,35h ; Read current vector INT 21h MOV WORD PTR OldR+0, BX ; Offset MOV WORD PTR OldR+2, ES ; Segment ; ----- Store New Vector in table ----- MOV AL, N ; N=vector number MOV AH,25h ; Set current vector MOV DX,offset MyIntN ; DS:CS = new function ptr INT 21h ; ----- Terminate and Stay Resident ----- MOV DX, offset Install ; All data & code up to install MOV CL,4 SHR DX,CL ; Specify memory in 16-byte paragraphs ADD DX,1 ; Round up (eg: 17/16+1=2 paragraphs) MOV AH,31h ; Exit, but keep in memory MOV AL,0 ; No error code INT 21h