;uses Vector 09H....Keyboard Interrupt to place Smiley Face Character ; in the Top-Right Corner of screen.... ; This Interrupt is 'activated' on any Key-Down & Key-Up ; motion...try holding a key down (auto_repeat)! Data Segment OldVect DD ? ;Old Vector address IntNo Equ 09H ;Interupt Number we are modifying Smiley DB 01H ;Alternate Smiley Face between 01 & 02 Data EndS Code Segment Assume CS:Code,DS:Data Prog_Start: Mov AX, Data Mov DS, AX Jmp ChgVector ;****************************************************************************** My_Int_TSR: Push DS Push DX ; Save DX Mov DX, Data ; TSR code needs DS set Mov DS, DX ; for accessing OldVect... Pop DX ; Now restore it.... PushF ; Call the Call OldVect ; Old Interrupt Routine Push SI Push ES Push AX ;Save the Registers Push DI ;that may be needed PushF ;by the caller (DOS) some times.. Mov AX, 0B800H ;Top-Right Corner of Screen Mov ES, AX Mov AX, 009EH Mov DI, AX Mov AL, Smiley STOSB ;Place AX Char. in top-left corner of screen Cmp Smiley, 01 JE Set_Two Mov Smiley, 01 Jmp Over_Two Set_Two: Mov Smiley, 02 Over_Two: PopF Pop DI Pop AX Pop ES Pop SI Pop DS ; Restore DS IRET ;*Return to the program you were running ; when the Interrupt occured..... ;****************************************************************************** ; Set the Interrupt Vector Segment & Offset Addresses for "IntNo" to ; our own routine... ChgVector: ;************ Save the Current Interupt Vector Address **************** ; Mov AL, IntNo ; Interrupt ; Mov AH, 35H ; DOS Int21H function to get Vector ; Int 21H Mov AX, 0 Mov ES, AX Mov DS, AX CLD ;Go Forware Mov SI, IntNo*4 LodSW Mov BX, AX ;Save AX result LodSW Mov CX, Data Mov Ds, CX Mov Word PTR OldVect, BX Mov Word PTR OldVect+2, AX ; Mov Word PTR OldVect, BX ; and Save ; Mov Word PTR OldVect+2, ES ; it.... ;******* Replace the Interupt Vector with the Address to our routine....... Mov AX, 0 ;Set ES to Memory Segment 0 Mov ES, AX ; 0000H Mov DS, AX CLD ;Go forward Mov DI, IntNo*4 ;Set DI offset to the 0Hth Interrupt CLI ;Disable Interrupts Mov AX, OffSet My_Int_TSR STOSW ; Place our My_Div0_Int offset Mov AX, CS ; and CS Segment Address STOSW ; in the INT 0 Vector Table STI ;Enable Interrupts ; Now EXIT from this program, leaving 20H Paragraphs of it in memory.... Mov DX, 20H ;*Tell TSR to keep 20H Paragraphs of ; 16 bytes each in memory Mov AH, 31H ;*Terminate process, Stay Resident in ; memory TSR Int 21H ;*DOS Int .... Exit Prog, Prog.stays ; in memory ;****************************************************************************** Code EndS End Prog_Start